如何自定义UIAlertView和UIAlertController的按钮
1个回答
展开全部
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告!" message:@"\n\n\n\n\n\n\n\n\n\n" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:cancelAction];
UIAlertAction *button = [UIAlertAction actionWithTitle:@"确定"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
//add code to make something happen once tapped
}];
NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"Hulk Hogan!"];
[hogan addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(1, 2)];
[alertController setValue:hogan forKey:@"attributedTitle"];
[alertController addAction:button];
[self presentViewController:alertController animated:YES completion:nil];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:cancelAction];
UIAlertAction *button = [UIAlertAction actionWithTitle:@"确定"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
//add code to make something happen once tapped
}];
NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"Hulk Hogan!"];
[hogan addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(1, 2)];
[alertController setValue:hogan forKey:@"attributedTitle"];
[alertController addAction:button];
[self presentViewController:alertController animated:YES completion:nil];
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询