使用UIAlertAction与图像而不是文本

时间:2015-01-14 16:40:38

标签: ios8 uialertcontroller uialertaction

我想基于UIAlertController创建一个星级选择组件。我目前的做法是

UIAlertController * view=   [UIAlertController
                             alertControllerWithTitle:@""
                             message:@"Minimum Rating"
                             preferredStyle:UIAlertControllerStyleActionSheet];

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

                     }];
[ok setValue:[UIImage imageNamed:@"starRating_1"] forKey:@"image"];

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

                     }];
[ok setValue:[UIImage imageNamed:@"starRating_2"] forKey:@"image"];

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

                     }];
[ok setValue:[UIImage imageNamed:@"starRating_3"] forKey:@"image"];

[view addAction:ok];
[view addAction:ok2];
[view addAction:ok3];
[self presentViewController:view animated:YES completion:nil];

不幸的是,图像左侧显示了附件视图。有没有办法使用图像代替AlertAction标题?

0 个答案:

没有答案