How to customize UITabBar text labels?

I set up the tab bar using methods from Ray Wenderlich and iOS Blog, but since I use light color as the background, the text shortcuts look awful and I want to change them to suit my style. Is it possible and how?

If this is not possible, or if it is too complicated, I would like to ask how to move the icon of the icon down to focus it on the tab bar? That way I could "write" tags in .png files.

I plan to develop this application for iOS5 +, so there is no concern about its compatibility with iOS4 (although if someone finds an easy way to do this, I would really appreciate it).

Here is what I got , and here is what I want .

Code for my tabBarBackground:

UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"]; [[UITabBar appearance] setBackgroundImage:tabBarBackground]; [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selection-tab.png"]]; 

And for the icons:

 //Custom TabBar Items UIImage *selectedImage = [UIImage imageNamed:@"home-icon-selected.png"]; UIImage *unselectedImage = [UIImage imageNamed:@"home-icon.png"]; UITabBar *tabBar = rootTabBarController.tabBar; //Icons for the 1st Tab UITabBarItem *item1 = [tabBar.items objectAtIndex:0]; [item1 setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage]; 
+4
source share
2 answers

You can do this by referring to the subject of the tab-bar element on the tab for each view controller. Check out some of the docs for more examples.

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html

+2
source

Use this to customize the text of UITabBarItem:

 [[UITabBarItem appearance] setTitleTextAttributes: aNSDictionaryOfTextAttributes]; 

with a dictionary of attributes similar to those shown in the answer here .

-1
source

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


All Articles