ios – 如何添加UIActionSheet按钮复选标记?

前端之家收集整理的这篇文章主要介绍了ios – 如何添加UIActionSheet按钮复选标记?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道如何在actionSheet按钮右侧添加复选标记最简单的方法
Bellow是Podcasts应用程序的屏幕截图.

解决方法

最后我通过使用UIAlertController得到了答案:
  1. UIAlertController *customActionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  2.  
  3. UIAlertAction *firstButton = [UIAlertAction actionWithTitle:@"First Button" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  4. //click action
  5. }];
  6. [firstButton setValue:[UIColor blackColor] forKey:@"titleTextColor"];
  7. [firstButton setValue:[UIColor blackColor] forKey:@"imageTintColor"];
  8. [firstButton setValue:@true forKey:@"checked"];
  9.  
  10. UIAlertAction *secondButton = [UIAlertAction actionWithTitle:@"Second Button" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  11. //click action
  12. }];
  13. [secondButton setValue:[UIColor blackColor] forKey:@"titleTextColor"];
  14.  
  15. UIAlertAction *cancelButton = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
  16. //cancel
  17. }];
  18. [cancelButton setValue:[UIColor blackColor] forKey:@"titleTextColor"];
  19.  
  20. [customActionSheet addAction:firstButton];
  21. [customActionSheet addAction:secondButton];
  22. [customActionSheet addAction:cancelButton];
  23.  
  24. [self presentViewController:customActionSheet animated:YES completion:nil];

这就是结果:

猜你在找的iOS相关文章