使用UIAlertController修改按钮颜色(iOS7以后)

UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"是否放弃本次编辑(本次输入内容将不生效)" preferredStyle:UIAlertControllerStyleAlert];
    
    
    //修改按钮的颜色
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"放弃本次编辑" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
        
        [self.navigationController popViewControllerAnimated:YES];
        
    }];
    [sure setValue:[UIColor colorWithRed:159/255.0 green:69/255.0 blue:69/255.0 alpha:1/1.0] forKey:@"_titleTextColor"];
    
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"继续编辑"style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
        
    }];
    [cancle setValue:[UIColor colorWithRed:159/255.0 green:69/255.0 blue:69/255.0 alpha:1/1.0] forKey:@"_titleTextColor"];
    [alert addAction:sure];
    [alert addAction:cancle];
    
    [self presentViewController:alert animated:YES completion:nil];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容