How to do a semi-transparent modal segue like “Whatsapp” - “Take Photo/ Choose Existing Photo”

让人想犯罪 __ 提交于 2019-12-11 03:44:58

问题


My idea is to create a semi-transparent view like whatsapp does.

1) I have a tap gesture on image view.

2) When I tap on the image view, one layer of transparent view like whatsapp will appear

3) I then have three button - take new, choose existing or cancel.

How do I continue from here? When I press cancel it should pop away the semi-transparent ui view..


回答1:


why dont you use UIActionSheet....try something like...

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];

also implement the action in the delegate method.....

-(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... 
    }
}

you will get something like>>



来源:https://stackoverflow.com/questions/19789938/how-to-do-a-semi-transparent-modal-segue-like-whatsapp-take-photo-choose-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!