你如何着色/自定义 UIImagePickerController 的导航栏? [英] How do you color/customize the UIImagePickerController's Navigation Bar?

查看:30
本文介绍了你如何着色/自定义 UIImagePickerController 的导航栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为 UIImagePickerController 的导航栏着色的正确方法是什么?
我只是想看看背景颜色,但我得到了一种褪色的颜色,如下图所示;好像有什么东西挡住了它.

What is the correct way to color the UIImagePickerController's nav bar?
I merely tried to see the background color but I'm getting a faded color as seen in the image below; as if some view is obstructing it.

let picker = UIImagePickerController()
picker.sourceType = type
picker.mediaTypes = [kUTTypeImage]
picker.delegate = self
picker.navigationBar.backgroundColor = UIColor.redColor()

它似乎有一些模糊 redColor() 的视图:

It appears to have some view obscuring the redColor():

(lldb) po picker.navigationBar.subviews
2 values
 {
  [0] = 0x00007fe7bb52a890
  [1] = 0x00007fe7bb52b670
}

为导航栏创建纯色的正确方法是什么?

What is the correct way to create a solid color for the Navigation Bar?

推荐答案

已针对 Swift 4.2 更新

为了完整起见,我将添加全彩色自定义设置:

For completeness, I'll add full color customization setup:

let imagePicker = UIImagePickerController()
imagePicker.navigationBar.isTranslucent = false
imagePicker.navigationBar.barTintColor = .blue // Background color
imagePicker.navigationBar.tintColor = .white // Cancel button ~ any UITabBarButton items
imagePicker.navigationBar.titleTextAttributes = [
        NSAttributedString.Key.foregroundColor: UIColor.white
] // Title color

导致:

这篇关于你如何着色/自定义 UIImagePickerController 的导航栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆