美文网首页
改变提示框文字颜色

改变提示框文字颜色

作者: sdr小米 | 来源:发表于2017-07-09 05:08 被阅读0次

NSString*title =@"重要提示❗️";

//改变 UIAlertController 标题颜色NSMutableAttributedString*str = [[NSMutableAttributedStringalloc]initWithString:title];   

 [str addAttribute:NSForegroundColorAttributeNamevalue:[UIColorcolorwithHexString:@"#00A0E9"] range:NSMakeRange(0,6)];

NSString*message = [NSStringstringWithFormat:@"删除之后不可恢复\n哈哈哈"];

NSString*cancelButtonTitle =NSLocalizedString(@"确定",nil);NSString*otherButtonTitle =NSLocalizedString(@"取消",nil);

UIAlertController*alertController = [UIAlertControlleralertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];

//改变 UIAlertController 按钮颜色##整个应用层级修改,即修改了整个应用的渲染色,一定要用的话,结束时要改回原来的值[UIViewappearance].tintColor = [UIColorcolorwithHexString:@"#00A0E9"];

//点击事件UIAlertAction*cancelAction = [UIAlertActionactionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancelhandler:^(UIAlertAction*action) {NSLog(@"234");    }];

UIAlertAction*otherAction = [UIAlertActionactionWithTitle:otherButtonTitle style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*action) { 

   }];

    [alertController setValue:str forKey:@"attributedTitle"];// Add the actions.[alertController addAction:cancelAction];   

 [alertController addAction:otherAction]; 

   [selfpresentViewController:alertController animated:YEScompletion:nil];

相关文章

网友评论

      本文标题:改变提示框文字颜色

      本文链接:https://www.haomeiwen.com/subject/tkcshxtx.html