如何做一个半透明模式segue像“Whatsapp” - “拍照/选择现有照片”

时间:2013-11-05 13:19:00

标签: ios iphone objective-c uitableview uicontainerview

我的想法是创建一个像whatsapp那样的半透明视图。

1)我在图像视图上有一个轻击手势。

2)当我点击图片视图时,会出现一层像whatsapp的透明视图

3)然后我有三个按钮 - 取新,选择现有或取消。 Storyboard

我如何从这里继续?当我按下取消时,它应该弹出半透明的ui视图..

1 个答案:

答案 0 :(得分:4)

为什么不使用UIActionSheet ....尝试类似......

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                      delegate:self
                                             cancelButtonTitle:@"Cancel"
                                        destructiveButtonTitle:nil
                                             otherButtonTitles:@"Take photo",@"Choose existing", nil];



            actionSheet.actionSheetStyle=UIActionSheetStyleBlackTranslucent;

           [actionSheet showFromRect:[sender frame] inView:self.view animated:YES];

也在委托方法中实现动作.....

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    // create an image picker controller
    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
     imagePickerController.delegate = self;

    if(buttonIndex==0)
    {
    //create image picker with source camera blah blah
    }
else if(buttonIndex==1)
    {
    //choose existing... 
    }
}

您将获得类似>>

的内容

enter image description here

相关问题