ios 11 UITabBar UITabBarItem positioning issue

前端 未结 7 1472
清酒与你
清酒与你 2020-12-02 13:03

I have built my app using new Xcode 9 beta for ios 11. I have found an issue with UITabBar where items are spread through the UITabBar and title is right aligned to the imag

7条回答
  •  失恋的感觉
    2020-12-02 13:38

    Swift 4 version with a subclass that avoids extension/category naming collision:

    class TabBar: UITabBar {
      override var traitCollection: UITraitCollection {
        guard UIDevice.current.userInterfaceIdiom == .pad else {
          return super.traitCollection
        }
    
        return UITraitCollection(horizontalSizeClass: .compact)
      }
    }
    

    If you use Interface Builder and storyboards, you can select the tab bar view in your UITabBarController scene and change its class to TabBar in the Identity Inspector:

提交回复
热议问题