UITabBar items jumping on back navigation on iOS 12.1

后端 未结 12 1012
北恋
北恋 2020-11-29 18:28

I have an iOS app with UITabBarController on a master screen, navigating to a detail screen hiding the UITabBarController with setting hidesB

12条回答
  •  伪装坚强ぢ
    2020-11-29 18:50

    If you still want to keep your tab bar translucent you need to subclass from UITabBar and override property safeAreaInsets

    class MyTabBar: UITabBar {
    
    private var safeInsets = UIEdgeInsets.zero
    
    @available(iOS 11.0, *)
    override var safeAreaInsets: UIEdgeInsets {
        set {
            if newValue != UIEdgeInsets.zero {
                safeInsets = newValue
            }
        }
        get {
            return safeInsets
        }
    } 
    

    }

    The idea is to not allow system to set zero insets, so tab bar won't jump.

提交回复
热议问题