0

我想创建一个基于 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 标题?

4

0 回答 0