我看过几个 UIAlertControllers 的屏幕截图,行的左侧有一个图像,但我没有在文档中看到它。视觉示例是 这是我现在为我的 Controller 准备的代码:
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];
最佳答案
这就是它是如何完成的:
let image = UIImage(named: "myImage")
var action = UIAlertAction(title: "title", style: .default, handler: nil)
action.setValue(image, forKey: "image")
alert.addAction(action)
image 属性没有公开,所以不能保证这个在未来的版本中工作,但现在工作正常
关于ios - 在 UIAlertController 中将图像添加到 UIAlertAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26347085/