将图像添加到UIAlertController中的UIAlertAction

我已经看到了UIAlertControllers的几个屏幕快照,在该行的左侧有一个图像,但是我在文档中没有看到它。视觉示例如下:

http://img3.mukewang.com/5db3dce7000127dd06401136.jpg

我现在为控制器使用的代码:


UIAlertController * view =   [UIAlertController

                                 alertControllerWithTitle:@"My Title"

                                 message:@"Select you Choice"

                                 preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction* ok = [UIAlertAction

                         actionWithTitle:@"OK"

                         style:UIAlertActionStyleDefault

                         handler:^(UIAlertAction * action)

                         {

                          }];

    [view addAction:ok];

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


DIEA
浏览 1006回答 2
2回答

至尊宝的传说

UIAlertController * view=   [UIAlertController                             alertControllerWithTitle:@"Staus ! "                             message:@"Select your current status"                             preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction* online = [UIAlertAction                     actionWithTitle:@"Online"                     style:UIAlertActionStyleDefault                     handler:^(UIAlertAction * action)                     {                         //Do some thing here                         [view dismissViewControllerAnimated:YES completion:nil];                     }];UIAlertAction* offline = [UIAlertAction                         actionWithTitle:@"Offline"                         style:UIAlertActionStyleDefault                         handler:^(UIAlertAction * action)                         {                             [view dismissViewControllerAnimated:YES completion:nil];                         }];UIAlertAction* doNotDistrbe = [UIAlertAction                         actionWithTitle:@"Do not disturb"                         style:UIAlertActionStyleDefault                         handler:^(UIAlertAction * action)                         {                             [view dismissViewControllerAnimated:YES completion:nil];                         }];UIAlertAction* away = [UIAlertAction                               actionWithTitle:@"Do not disturb"                               style:UIAlertActionStyleDestructive                               handler:^(UIAlertAction * action)                               {                                   [view dismissViewControllerAnimated:YES completion:nil];                               }];[online setValue:[[UIImage imageNamed:@"online.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];[offline setValue:[[UIImage imageNamed:@"offline.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];[doNotDistrbe setValue:[[UIImage imageNamed:@"DND.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];[away setValue:[[UIImage imageNamed:@"away.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];[view addAction:online];[view addAction:away];[view addAction:offline];[view addAction:doNotDistrbe];[self presentViewController:view animated:YES completion:nil];
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

iOS