Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you color/customize the UIImagePickerController's Navigation Bar?

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() 

enter image description here

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?

like image 306
Frederick C. Lee Avatar asked Nov 27 '14 06:11

Frederick C. Lee


People also ask

How can I change navigation bar color?

Tap the Gear icon next to Active App on the home screen and you can disable coloring for certain apps, or override the default color if you'd prefer another. If you'd rather keep it at one color, choose Static Color on the home screen. Tap the Gear to select your color. This is all you need to get a colored status bar.

How do I color a navigation bar in Swift?

navigationBar. barTintColor = UIColor. newBlueColor() and of course this just changes the colour of the navigation bar of the view controller that the code is within.

How do I make my navigation bar opaque?

Go to attribute inspector of for Navigation bar and remove check mark from translucent.


1 Answers

Updated for 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 

which results in:

enter image description here

like image 72
Michal Avatar answered Nov 15 '22 19:11

Michal