为了账号安全,请及时绑定邮箱和手机立即绑定

将图像添加到UIAlertController中的UIAlertAction

将图像添加到UIAlertController中的UIAlertAction

iOS
DIEA 2019-10-26 13:42:14
我已经看到了UIAlertControllers的几个屏幕快照,在该行的左侧有一个图像,但是我在文档中没有看到它。视觉示例如下:我现在为控制器使用的代码: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];
查看完整描述

2 回答

?
至尊宝的传说

TA贡献1789条经验 获得超10个赞

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


查看完整回答
反对 回复 2019-10-26
  • 2 回答
  • 0 关注
  • 998 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信