Using a 'launch storyboard'. It's quite simple, and contains a default UITabBarController. I've set the tab bar's 'tintColor' to red in the launch storyboard, as well as in my app. I'm using Xcode 7, iOS 9.
The launch screen loads the tab bar using the default blue iOS tint color...! Then after loading, the tint color switches to red when the launch screen storyboard is replaced.
How on earth are you meant to set a tab bar's tint color in a storyboard?
Demo Project: http://s000.tinyupload.com/?file_id=73998115878034693063
backgroundColor = UIColor(red:1, green:0, blue:0, alpha:1) / UITabBar. appearance(). tintColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1) // New!! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {...}
tintColor is a variable in UIView that returns a color. The color returned is the first non-default value in the receiver's superview chain (starting with itself). If no non-default value is found, a system-defined color is returned (the shiny blue you always see).
The right way to go is to confuse Xcode. Xcode should not know that the launch storyboard that is used is actually a launch
storyboard. This way you would be able to set some custom User Defined Runtime Attributes
. However, you still would NOT be able to run some custom code...
So... To do this, follow these steps:
Create a new Xcode project
Copy your Main.storyboard
into desktop and rename it to CustomLaunchScreen.storyboard
.
Add this CustomLaunchScreen.storyboard
to the project.
Open your Info.plist file
and change key Launch screen interface file base name
value from LaunchScreen
to CustomLaunchScreen
.
Open your CustomLaunchScreen.storyboard
. Delete the default UIViewController
and set the UITabBarController
as your initial view controller
.
Open the tabBar
property of your UITabBarController
and navigate to User Defined Runtime Attributes
Add the tintColor
property, set type
as Color
and set some custom value.
You can also watch a full video tutorial Here
Well thanks to @OIDor for his solution, it is a great hack.
To be clear however, you don't need to do all that. All you have to do is:
launchScreen="YES"
to launchScreen="NO"
, this enables you to do the
next part...tintColor
on the Tab Bar
in the storyboard. This is not permitted by Xcode without the first
stepHey presto it's all working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With