UITabBarItem with custom color and header images

I am trying to configure my TabBar in xcode, ios, however I just found ppl saying it is not configurable! Also, I found some solutions, but none of them work for me.

Basically I want to change the color of the UITabBarItem header (text), and also change 2 images inside it, normal and selected!

I tried iterating inside my UITabBar routines to see if I would find something, but any success:

for (UIView *view in [self.tabBarController tabBar].subviews) { NSLog(@"Class: %@",[view class]); } 

output of this:

 2011-05-18 18:15:24.031 EventApp[52235:207] Class: UIImageView 2011-05-18 18:15:24.032 EventApp[52235:207] Class: UITabBarButton 2011-05-18 18:15:24.032 EventApp[52235:207] Class: UITabBarButton 2011-05-18 18:15:24.033 EventApp[52235:207] Class: UITabBarButton 2011-05-18 18:15:24.033 EventApp[52235:207] Class: UITabBarButton 2011-05-18 18:15:24.034 EventApp[52235:207] Class: UITabBarButton 

and I can not import UITabBarButton obj to work with it!

Some solution for this ?! I also posted a few links that I looked, but did not work!

UITabBarItem custom image / name on iPhone

uitabbaritem text color change

EDIT I want to do something like the following: enter image description here

+6
source share
3 answers

And I am one of those who say that this really does not work. You must override all functionality in a custom UIViewController that acts as a replacement for a UITabBar.

Just like Twitter for iPhone or Tweetbot.

enter image description here

+7
source

In iOS 5.0 and later, you can Customize UITabBar Appearance by changing the color of the shades, the background image and the selection indicator so that they look the way you like.

You can also configure individual UITabBarItems by calling the setFinishedSelectedImage: withFinishedUnselectedImage: method with pre -selected and unselected images as parameters.

Alternatively, changing the external proxy of UITabBar allows you to change the aspect of all its instances.

+9
source

Not fully customizable. You either use what is provided to you by Apple (mask images for figures and captions), or you roll your own.

One of the ways that worked for me is to subclass the tab bar. Use your own subtitles to make the tab bar look the way you want it to. For example: use a background image and dynamically overlay it using the buttons for each of the tabBarItems.

Thus, you can customize the tab bar in Interface Builder, and you get free switching of the contents of the tab bar. At the same time, the tab bar will look the way you want.

+2
source

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


All Articles