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

2017-06-01  本文已影响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];
上一篇下一篇

猜你喜欢

热点阅读