美文网首页
使用UIAlertController修改按钮颜色(iOS7以后

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

作者: 夜未殇 | 来源:发表于2017-06-01 17:09 被阅读0次
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];

相关文章

网友评论

      本文标题:使用UIAlertController修改按钮颜色(iOS7以后

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