How to set tab bar item title programmatically in objective c?

前端 未结 10 1370
猫巷女王i
猫巷女王i 2021-01-31 15:46

I want to set title to tab item programatically, but it not works. My code is below:

- (IBAction)tab1Click:(id)sender {
    myTabBarController = [[UITabBarContro         


        
10条回答
  •  生来不讨喜
    2021-01-31 16:18

    try this

    [(UIViewController *)[tabBarController.viewControllers objectAtIndex:Index] setTitle:@"Title"]; 
    

    or also you can set tab bar by in this way

    UITabBarItem *tabItem = [[[tabBarController tabBar] items] objectAtIndex:INDEX];
    [tabItem setTitle:@"TITLEe"];
    

提交回复
热议问题