Set tab strip names programmatically

I have five tabs in my main window, but I did not create it programmatically.

What should I do to create a header through code?

+5
source share
4 answers

Hey do you want to set the tab title of the tab bar or tab view manager?

If you are looking for the first, then do it like this:

UITabBarItem *tabItem = [[[tabBarController tabBar] items] objectAtIndex:yourIndex];
[tabItem setTitle:@"theTitle"];

otherwise mihirpmehtacorrect.

Hope this helps.

+12
source

OR

[(UIViewController *)[tabBarController.viewControllers objectAtIndex:1] setTitle:@"Title1"];
+5
source

UITabBarItem, :

- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag; // selected image autogenerated
- (id)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag

tabBar:

- (void)setItems:(NSArray *)items animated:(BOOL)animated;

items id - , tabBarItem. badgeValue UITabBarItem, .

0

UIViewController UINavigationController, :

self.navigationController?.tabBarItem.title = "Awesome Title"
0

All Articles