UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:@"刪除" style:UIAlertActionStyleDestructive handler:nil];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:destructiveAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
//修改title
NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:@"提示"];
[alertControllerStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
[alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
[alertController setValue:alertControllerStr forKey:@"attributedTitle"];
//修改message
NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:@"提示內(nèi)容"];
[alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 4)];
[alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, 4)];
[alertController setValue:alertControllerMessageStr forKey:@"attributedMessage"];
作者:PlutoMa
鏈接:http://www.reibang.com/p/51949eec2e9c
來源:簡書
著作權歸作者所有章钾。商業(yè)轉載請聯(lián)系作者獲得授權,非商業(yè)轉載請注明出處。