改变提示框文字颜色

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

你可能感兴趣的:(改变提示框文字颜色)