iOS开发UIAlertController之UIAlertAction加图片(UIAlertController按钮加图片)
废话不多说,直接上代码
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"SWFT Blockchain" message:@"Enjoying SWFT Blockchain" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"给一个超级牛逼的好评" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *urlStr = [NSString
stringWithFormat:@"https://itunes.apple.com/us/app/itunes-u/id%@?action=write-review&mt=8",
@"1435569339"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
}]];
//这里是重点
UIAlertAction *secondAction = [UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault handler:nil];
UIImage *secondImage = [[UIImage imageNamed:@"grade_star"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[secondAction setValue:secondImage forKey:@"image"];
[alert addAction:secondAction];
// [alert addAction:[UIAlertAction actionWithTitle:attri style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// }]];
[alert addAction:[UIAlertAction actionWithTitle:@"Remind me later" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
[self presentViewController:alert animated:true completion:^{
}];