美文网首页
iOS修改控件颜色(弹窗、返回按钮文字、导航栏文字颜色)

iOS修改控件颜色(弹窗、返回按钮文字、导航栏文字颜色)

作者: 不要虚度美好的时光 | 来源:发表于2021-01-12 14:27 被阅读0次
  1. 弹窗颜色(确定、取消,由蓝色改成黑色):
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"重要!确定要情况所有提示任务吗?" preferredStyle:UIAlertControllerStyleAlert];
    
    //    __weak __typeof(self) weakSelf = self;
    UIAlertAction* btn1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        // TODO: 清空所有提醒任务!!
        
    }];
    
    UIAlertAction* btn2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [btn1 setValue:[UIColor blackColor] forKey:@"_titleTextColor"];
    [btn2 setValue:[UIColor blackColor] forKey:@"_titleTextColor"];

    [alert addAction : btn1];
    
    [alert addAction : btn2];
    
    [self  presentViewController:alert animated:YES  completion:nil];
  1. 导航栏文字颜色、返回按钮文字
self.navigationController.navigationBar.tintColor=[UIColor blackColor];
  1. iOS 修改导航栏上返回按钮上的文字,例如把 back 修改为 返回
 UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] init];
     backBtn.title = @"返回";
     self.navigationItem.backBarButtonItem = backBtn;   // 注意这里的self是父ViewController,不是即将显示的子ViewController

4.iOS修改导航栏字体大小、颜色

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20 weight:9],NSForegroundColorAttributeName:[UIColor redColor]}];

相关文章

网友评论

      本文标题:iOS修改控件颜色(弹窗、返回按钮文字、导航栏文字颜色)

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