What I'm doing:
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.
What doesn't work:
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
I think I've figured this out.
There are quite a few blog posts online about how Launch Storyboards work, but not a lot from Apple. I found from this blog post which discussed that the launch screen images are captured at runtime from the launch storyboard. Digging into my simulator directory revealed that they were in fact there:
I'm not sure why, but the call to set the
UITabBar
'stintColor
does not fire in time when the launch storyboard has loaded, but setting colors for other values such as thebarTintColor
property works:All I can say is this: setting the
tintColor
on aUITabBar
on a view controller in a launch storyboard is not supported. There is something going on behind-the-scenes when the launch storyboard is loaded preventing this from working.TL;DR: you can't do this with a Launch Storyboard. For a workaround that tricks Xcode into treating your launch storyboard as a regular storyboard, see OlDor's answer.
As an alternative, you could take a screenshot of your app with the tab bar loaded properly, tweak it, and use that in a
UIImageView
on your launch view controller.If you want to add just the tab bar without any currently selected tabs, add a
UITabBar
to your launchUIViewController
and style theUITabBarItem
s to your liking:This
UITabBar
has twoUITabBarItems
which can be styled without adding outlets to their view controllers.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"
tolaunchScreen="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.
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 customUser 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 toCustomLaunchScreen.storyboard
.Add this
CustomLaunchScreen.storyboard
to the project.Open your
Info.plist file
and change keyLaunch screen interface file base name
value fromLaunchScreen
toCustomLaunchScreen
.Open your
CustomLaunchScreen.storyboard
. Delete the defaultUIViewController
and set theUITabBarController
as yourinitial view controller
.Open the
tabBar
property of yourUITabBarController
and navigate toUser Defined Runtime Attributes
Add the
tintColor
property, settype
asColor
and set some custom value.You can also watch a full video tutorial Here