系统提示框字体、字号修改方法

项目中有电话号码在拨打前会有一个提示框,boss觉得字号太小,看不清楚。奈何找来找去也没找到在ios8以后UIAlertView如何修改。今天用UIAlertController搜了一下,居然搜到了:

内容:[alertController setValue:msg forKey:@"attributedMessage"];

标题:[alertController setValue:msg forKey:@"attributedTitle"];

完整代码:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:self.telLabel.text preferredStyle:UIAlertControllerStyleAlert];

NSMutableAttributedString *msg = [[NSMutableAttributedString alloc] initWithString:self.telLabel.text];

[msg addAttribute:NSFontAttributeName

value:[UIFont boldSystemFontOfSize:17.0]

range:NSMakeRange(0, self.telLabel.text.length)];

[alertController setValue:msg forKey:@"attributedMessage"];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];

UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"呼叫" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",weakSelf.telLabel.text]]];

}];

[alertController addAction:cancelAction];

[alertController addAction:okAction];

[self presentViewController:alertController animated:YES completion:nil];

你可能感兴趣的:(系统提示框字体、字号修改方法)