UIImagePickerController Navigation Bar Tint Color not working with iOS 13
This was resolved with rmaddy's solution in the comments.
in AppDelegate
implement;
func configureGlobalUI() {
UINavigationBar.appearance().tintColor = .red
}
then call in didFinishLaunchingWithOptions
This works as I require the tintColor
on all navigationBar
appearances.
How can I change UIImagePickerController navigation bar font?
This is how you do it:
picker.navigationBar.titleTextAttributes =
[NSForegroundColorAttributeName: UIColor.redColor(),
NSFontAttributeName: UIFont.init(name: "Helvetica", size: 21)!]
Also, a small problem with your code: UIImagePickerController
derived from UINavigationController
, and picker.navigationController?
is always nil
in your code above.
Change UIImagePicker Navigation Bar style to blue
I think there is no way to change it. So my solution is using Color Meter to get the color of the default navigation bar in color code: red code, blue code, green code. Then I use the method
imagePicker.navigationBar.tintColor = [UIColor colorWithRed:redCode green:greenCode blue:blueCode alpha:0.1];
UINavigationBar tintColor
UIColor Reference
Change TintColor of UIImagePickerController
After you change window?.tintColor
, inputAccessoryView.tintColor
isn't changed because inputAccessoryView
isn't a subview of current window (they don't have same view’s hierarchy) so window.tintColor
won't affect inputAccessoryView
.
To resolve problem, I suggest to use NotificationCenter
to observe and change window.tintColor
each time a new UIWindow
becomes visible. You can put the code inside AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
NotificationCenter.default.addObserver(self, selector: #selector(self.windowDidBecomeVisible), name: .UIWindowDidBecomeVisible, object: nil)
return true
}
@objc func windowDidBecomeVisible(notification: NSNotification) {
// Each time an `UIWindow` becomes visible, change its |tintColor|
let visibleWindow = notification.object as! UIWindow
visibleWindow.tintColor = .red
}
If you want to change tintColor
only for the UIImagePickerController
, you need to change tintColor
for every view which is displayed on UIImagePickerController
.
Define an extension to change all subview's
tintColor
.extension UIView {
func changeTintColor(color: UIColor) -> Void {
for view in subviews{
view.tintColor = color
view.changeTintColor(color: color);
}
}
}Use
UINavigationControllerDelegate
to getUIViewController
which is displayed onUIImagePickerView
. Change view'stintColor
inside this controllerfunc navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
viewController.view.changeTintColor(color: .red)
}Don't forget to set
UIImagePickerController
'sdelegate
toself
.
Incorrect navigation bar colour in limited library picker on iOS 15
The way to get completely control over a navigation bar's color is to use a background image. Make an image renderer. Fill the context with solid red and extract the image from the renderer. Call setBackgroundImage
on the appearance proxy.
I don't have time to translate the code from Swift to Objective-C so I leave it up to you:
let rend = UIGraphicsImageRenderer(size:.init(width:100, height:100))
let im = rend.image {
con in
UIColor.red.setFill()
con.fill(.init(x: 0, y: 0, width: 100, height: 100))
}
UINavigationBar.appearance().setBackgroundImage(im, for: .default)
Related Topics
"Missing Required Entitlement" for Nfctagreadersession
Why Is There a Memory Leak at String Creation in Swift
Swift Diffabledatasource Make Insert&Delete Instead of Reload
Convert or Cast Object to String
Swift: How to Animate the Rowheight of a Uitableview
Can't Able to Get Video Tracks from Avurlasset for Hls Videos(.M3U8 Format) for Avplayer
Format Float Value with 2 Decimal Places
Get Path to Swift Script from Within Script
Detect Ethernet/Wifi Network Change
Compiler Error: Invalid Library File - Corelocation
What Does the Swift 'Mutating' Keyword Mean