More Tab, Row Image Tint (Xcode 9 + Swift 4) - ios

so I'm using the native "more" function for tab bars in Xcode. I've managed to style the navigation bar & title color programmatically.
//sets the font color
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white]
//sets the tint color, which dictates the button color
UINavigationBar.appearance().tintColor = UIColor.white
//sets the Bar tint color
UINavigationBar.appearance().barTintColor = UIColor(red: 0/255, green: 175/255, blue: 65/255, alpha: 1.0)
But is there a way to change the tint on these blue icons (reference images below)? The images I'm uploading are green, but it's being tinted & I can't find the setting. Does anyone know how to change this?
Image 1, Image 2

You only need to initialize the image:
UIImage.(withRenderingMode: .alwaysTemplate)
and then change
UIImageView.tintColor = .green

Related

Tab Bar Controller: Icon and Colors when switching to dark mode

When I switch my app to dark mode this is what happens to the tab bar. How can i make the tapped icon fully visible in the dark mode environment?
im using the runtime property tintColor to automatically change the color and it's set in this way
tintColor = Label
You should use the traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) function of UIView/UIViewController to detect changes in the interface environment (including changes in the user interface style).
Then after checking it you can change the color of the TabBar icons depending on the selected mode by using the below:
UITabBar.appearance().barTintColor = #colorLiteral(red: 0.2000651062, green: 0.1960035861, blue: 0.2000851929, alpha: 1)
UITabBar.appearance().tintColor = #colorLiteral(red: 0.2000651062, green: 0.1960035861, blue: 0.2000851929, alpha: 1)
UITabBar.appearance().unselectedItemTintColor = #colorLiteral(red: 0.7415059209, green: 0.5448099971, blue: 0.5051562786, alpha: 1)
and you can check your colors depending on your App.

How to change my navigation title font and color both together? [duplicate]

This question already has an answer here:
Change Both Title Text Color and Font in all Navigation Bars
(1 answer)
Closed 4 years ago.
I want to change my custom navigation bar's background color and also its title font color , font style and font size. so i tried this code into the AppDelegate.swift file
UINavigationBar.appearance().barTintColor = UIColor(red: 0/255, green: 162/255, blue: 255/255, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.white
let navigationTitleFont = UIFont(name: "Poppins", size: 20)!
let navigaiontitlecolor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : navigaiontitlecolor]
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.font : navigationTitleFont]
i got the background color. my title font style and size both are ok. but my title font color is not ok. so i go for searching and i applied this link code
Change Both Title Text Color and Font in all Navigation Bars
but did not work in my case. what to do?
Below code will globally change the UINavigationBar style and also remove its bottom line. Just paste them to didFinishLaunchingWithOptions inside AppDelegate
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = UIColor(red: 0/255, green: 162/255, blue: 255/255, alpha: 1.0)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().isTranslucent = true
UINavigationBar.appearance().titleTextAttributes = [
NSAttributedString.Key.font: UIFont(name: "Poppins", size: 20)!,
NSAttributedString.Key.foregroundColor: UIColor.white
]
try this to change navigation title font and color both together:
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: **YourFont**, NSAttributedStringKey.foregroundColor:**Your Color**]

iOS Navbar Appearing Faded

The navbar color appears faded at the top. I'm using a UINavigationController, and the navbar is showing up a lot lighter than it should. Any ideas on how to fix it? Here is my code:
self.navigationController!.navigationBar.hidden = false
self.navigationController!.navigationBar.backgroundColor = UIColor(red: 0.459, green: 0.102, blue: 1, alpha: 1)
let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController!.navigationBar.titleTextAttributes = titleDict as? Dictionary
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
Add these lines to your .plist file. Then, set style Black and you problem should be fixed.
1.Do the following change
2.You are setting background color so it is faded but we have to set bartint color
self.navigationController?.navigationBar.barTintColor = UIColor.red
This will set the bartint color to red, you can set any you want

iOS UINavigationBar Style issues

I have an issue with UINavigationBar styling:
1) I have applied style change in the AppDelegate.swift:
//Change Navigation bar appearance
UINavigationBar.appearance().barTintColor = UIColor (red: 231.0/255.0, green: 95.0/255.0, blue: 53.0/255.0, alpha: 0.3)
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
if let barFont = UIFont (name: "AvenirNextCondensed-DemiBold", size: 22.0){
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: barFont, NSForegroundColorAttributeName: UIColor.whiteColor()]
}
//Status bar text change to white
UIApplication.sharedApplication().statusBarStyle = .LightContent
//Toolbar Buttons color change
UIBarButtonItem.appearance().tintColor = UIColor(red: 235.0/255.0, green: 73.0/255.0, blue: 27.0/255.0, alpha: 1.0)
UIToolbar.appearance().barTintColor = UIColor(red: 237.0/255.0, green: 240.0/255.0, blue: 243.0/255.0, alpha: 0.5)
2) I launch the app and go from main view to the connected one using push segue in the same navigation controller (this issue won't appear if I use modal segue) and unwind to the first view
3) Navigation Bar loses the title and styling, status bar also loses changed style. Though if I change it (style and title) once again in ViewWillAppear - it works fine.
The question is: should this work like that and one has to reload styling in every ViewWillAppear or am I doing something wrong?
Thanks in advance!
Michael

What is the default background color of the navigation bar in iOS 7?

I would like to set the background color of a menu to that of the navigation bar. What is the best way to do this?
The default navbar color in iOS 7 is [UIColor colorWithRed:(247.0f/255.0f) green:(247.0f/255.0f) blue:(247.0f/255.0f) alpha:1];
Swift 5
Nav bar color in light appearance:
UIColor(red: 0.969, green: 0.969, blue: 0.969, alpha: 1.0)
To get the tint color of a navigation bar, do this:
[aNavbar barTintColor]
By using this when you set the background color of your menu, you will not have to change it in case you change your navigation bar tint.
Swift 4
I am not sure the color does not change from version to version. In my app I use this:
var navBarDefaultColor: UIColor?
// save:
navBarDefaultColor = self.navigationController?.navigationBar.tintColor
//restore:
self.navigationController?.navigationBar.tintColor = navBarDefaultColor!
In Swift, it is:
UIColor(colorLiteralRed: (247/255), green: (247/255), blue: (247/255), alpha: 1)
Swift 3.0 +
UIColor(red: (247/255), green: (247/255), blue: (247/255), alpha: 1)
You can set the barTintColor to nil to restore to the default white color.
Swift 5:
UINavigationBar Default barTintColor for Light Mode.
#colorLiteral(red: 0.9763854146, green: 0.9765252471, blue: 0.9763546586, alpha: 1)

Resources