1.设置
2.富文本
//1.修改title
NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:@"物品详情"];
[alertControllerStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)]; //物品2个字为红色
[alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
[alertController setValue:alertControllerStr forKey:@"attributedTitle"];
//2.修改message
NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:@"轻便的移动电源很容易就电量耗尽,而大容量的移动电源往往都比较笨重,这样的体验远远比不上直接更换电池。"];
[alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 10)];
[alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(11, 20)];
[alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(20, 30)];
[alertController setValue:alertControllerMessageStr forKey:@"attributedMessage"];
//3.修改按钮的颜色
[cancelAction setValue:[UIColor orangeColor] forKey:@"titleTextColor"];