Roll out iOS newsletters: how do I change the color of a tab bar hue?

What am I doing:

Using a storyboard. It is quite simple and contains a default UITabBarController. I set the โ€œtintColorโ€ tab bar to red in the startup storyboard, as well as in my application. I am using Xcode 7, iOS 9.

What does not work:

The startup screen loads the tab bar using the default shades of blue iOS iOS ...! Then, after loading, the hue color switches to red when replacing the startup screen storyboard.


How do you actually want to set the hue color of the tab bar in the storyboard?

Demo project: http://s000.tinyupload.com/?file_id=73998115878034693063

+5
source share
3 answers

The right way is to confuse Xcode. Xcode should not know that the version of the storyboard used is the launch storyboard. This way you can set up custom User Defined Runtime Attributes . However, you still will NOT be able to run some kind of custom code ...

So ... To do this, follow these steps:

  • Create a new Xcode project

  • Copy Main.storyboard to your desktop and rename it to CustomLaunchScreen.storyboard .

  • Add this CustomLaunchScreen.storyboard to the project.

  • Open Info.plist file and change the value of Launch screen interface file base name from LaunchScreen to CustomLaunchScreen .

  • Open CustomLaunchScreen.storyboard . Remove the default UIViewController and set the UITabBarController as your initial view controller .

  • Open the tabBar property of your UITabBarController and go to User Defined Runtime Attributes

  • Add a tintColor property, set type to Color and set some custom value.

You can also watch the full video tutorial here.

+4
source

Well thanks to @OIDor for solving it, this is a great hack.

To be clear, you do not need to do all this. All you have to do is:

  • Edit the source of the startup screen storyboard and change launchScreen="YES" to launchScreen="NO" , this allows you to complete the next part ...
  • Add a custom tintColor attribute to the tab bar in the storyboard. This is not allowed by Xcode without the first step.

Hi, it all works.

+1
source

I think I figured it out.

There are many blog posts on the Internet about how boosters work, but not many from Apple. I found from this blog post that said that startup screen images are captured at run time from the startup storyboard. Digging into my catalog of simulators, it turned out that they were there:

launch1

I'm not sure why, but the call to install UITabBar tintColor does not work when loading the startup storyboard, but setting colors for other values, such as the barTintColor property, works:

launch2

All I can say is this: installing tintColor on a UITabBar on a view controller in a startup storyboard is not supported. Something happens behind the scenes when the storyboard loads, preventing it from working.

TL DR: you cannot do this with the Launch booster. . A workaround that allows you to use Xcode to process the storyboard of your launch as a regular storyboard, see OlDor's answer .

Alternatively, you can take a screenshot of your application with the correctly loaded tab bar, configure it and use it in UIImageView on your launch view controller.

If you want to add only the tab bar without any tabs selected, add a UITabBar to your UIViewController launch and configure the UITabBarItem to your liking:

tab

There are two UITabBarItems in this UITabBar that can be styled without adding outputs to their view controllers.

0
source

Source: https://habr.com/ru/post/1244323/


All Articles