我想基于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标题?