ios 11 UITabBar UITabBarItem positioning issue

前端 未结 7 1471
清酒与你
清酒与你 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:44

    Based on John C's answer, here is the Swift 3 version that can be used programmatically without need for Storyboard or subclassing:

    extension UITabBar {
        // Workaround for iOS 11's new UITabBar behavior where on iPad, the UITabBar inside
        // the Master view controller shows the UITabBarItem icon next to the text
        override open var traitCollection: UITraitCollection {
            if UIDevice.current.userInterfaceIdiom == .pad {
                return UITraitCollection(horizontalSizeClass: .compact)
            }
            return super.traitCollection
        }
    }
    

提交回复
热议问题