1

While using title property, it get sets for both i.e navigationBar and tabBar item for that VC

title = "This is Home"

I want to set different titles for both.

enter image description here

Creeky Crap
  • 71
  • 1
  • 5
  • have you tried using `UITabBarItem` ? – Visal Rajapakse Sep 14 '21 at 07:57
  • Please provide some additional context so we can give an answer. – Visal Rajapakse Sep 14 '21 at 07:58
  • @VisalRajapakse I am trying to create an app with multiple viewcontrollers which are embedded in their respective UINavigationControllers which itself are embedded in UITabBarController for quick access, for example you can think of it just like the Clock app on iPhone. I want to set different titles for navigationBar and UITabBarItem item but on using title property both titles reflect same name as evident in above image for selected home VC. – Creeky Crap Sep 15 '21 at 15:53
  • I think I get what you require. But from my experience (correct me if my perception of what you need is wrong) adding a `UINavigationView` over the `UITabBarController` will make things far easier: Less `UINavigationControllers` and you can easily use `UITabBarItem` to change the titles of both the tabbar and navbar title. If you can include some code so I can look into it would be great! – Visal Rajapakse Sep 15 '21 at 16:04
  • 1
    @VisalRajapakse i finally found out how to set different titles both for navigationBar as well as tabBarItem, navigationItem.title = "YourTitle" and passing tabBarItem title using UITabBarItem(title: "title", image: someUIImage, selectedImage: someUIImage). Thanks – Creeky Crap Sep 17 '21 at 16:53

1 Answers1

2

title = "This is home" self.navigationItem.title = "some label" //you change your title of navbar then you change the title with code above and this code automatically change tabor item title and all this code write in viewdidload