如何像Apple Music一样创建UIActionSheet或UIAlertController(UIAlertControllerStyleActionSheet)?

时间:2016-01-23 11:39:18

标签: ios objective-c uiactionsheet uialertcontroller

在我的应用中,我想像Apple Music一样创建UIActionSheetUIAlertController (UIAlertControllerStyleActionSheet)

我想在UIActionSheet的第一行显示用户个人资料图片和用户的一些基本详情,以及普通UIActionSheet等其他选项。

Apple Music My Requiremnt

1 个答案:

答案 0 :(得分:0)

在某种程度上,我可以为您提供问题的样本编码

UIAlertController *alertMusicVideos =   [UIAlertController
                             alertControllerWithTitle:@"Music Videos"
                             message:nil
                             preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *actionAddProfilePhoto = [UIAlertAction
                     actionWithTitle:@""
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         //Do Whatever you want to do here 
                         [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                     }];

UIAlertAction *actionPlayNext = [UIAlertAction
                     actionWithTitle:@"Play Next"
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         //Do some thing here
                         [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                     }];
UIAlertAction *actionAddToUpNext = [UIAlertAction
                         actionWithTitle:@"Add to Up Next"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                             //Do Whatever you want to do here when click this button
                             [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                         }];
UIAlertAction *actionAddToPlayList = [UIAlertAction
                         actionWithTitle:@"Add To PlayList"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                              //Do Whatever you want to do here when click this button
                             [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                         }];
UIAlertAction *actionDeleteFromMyMusic = [UIAlertAction
                               actionWithTitle:@"Delete From My Music"
                               style:UIAlertActionStyleDestructive
                               handler:^(UIAlertAction * action)
                               {
                                    //Do Whatever you want to do here when click this button
                                   [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                               }];

 UIAlertAction *actionCancel = [UIAlertAction
                               actionWithTitle:@"Cancel"
                               style:UIAlertActionStyleDestructive
                               handler:^(UIAlertAction * action)
                               {
                                    //Do Whatever you want to do here when click this button
                                   [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                               }];

[actionAddProfilePhoto setValue:[[UIImage imageNamed:@"yourProfile.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];

[alertMusicVideos addAction:actionAddProfilePhoto];
[alertMusicVideos addAction:actionPlayNext];
[alertMusicVideos addAction:actionAddToUpNext];
[alertMusicVideos addAction:actionAddToPlayList];
[alertMusicVideos addAction:actionDeleteFromMyMusic];
[alertMusicVideos addAction:actionCancel];

[self presentViewController:alertMusicVideos animated:YES completion:nil];