UIImagePickerController导航字体颜色和背景

Posted 伟大是熬出来的

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UIImagePickerController导航字体颜色和背景相关的知识,希望对你有一定的参考价值。

创建UIImagePickerController 

 // 创建图片选择器
            UIImagePickerController *picker = [[UIImagePickerController alloc] init];
            picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
            picker.allowsEditing = YES;
            picker.delegate = self;

             //设置导航栏背景颜色

             picker.navigationBar.barTintColor = HexRGB(0x4294FE);

             //设置右侧取消按钮的字体颜色

             picker.navigationBar.tintColor = [UIColor whiteColor]; // 以富文本方式更改[picker.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:18]}];

           [self presentViewController:picker animated:YES completion:nil];

 

右侧取消按钮的字体方式无效可使用代理方法

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [viewController.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]} forState:UIControlStateNormal];
    
    [viewController.navigationItem.leftBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]} forState:UIControlStateNormal];
}

 

以上是关于UIImagePickerController导航字体颜色和背景的主要内容,如果未能解决你的问题,请参考以下文章

UIImagePickerController导航字体颜色和背景

添加到 UIPopoverController 时,UIImagePickerController 中缺少导航按钮

你如何为 UIImagePickerController 的导航栏着色/自定义?

如何在嵌入式 UIImagePickerController 中隐藏导航栏

更改系统相机UIImagePickerController导航栏的cancle为取消按钮

现有 UIPopoverController 中的 UIImagePickerController