Search code examples
iosswiftuikituitabbarios13

Using UITabBar.ItemPositioning in iOS 13


My UITabBarController has just two items and I want to display them closer together. This worked for me in XCode 10 / iOS 12:

override func viewDidLoad() {
    super.viewDidLoad()        
    tabBarController?.tabBar.itemPositioning = .centered
}

However, it no longer works in XCode 11 / iOS 13 - the items are spaced in the default fashion.

The documentation now refers to UITabBar.ItemPositioning as "Legacy customizations". So what is one supposed to use instead, if anything?


Solution

  • You can set it from the interface builder. Select TabBar -> Attribute Inspector -> Item Position -> Center then you will get item spacing option.

    enter image description here