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"];