How to correct Tab Bar height issue on iPhone X

前端 未结 20 3590
长发绾君心
长发绾君心 2020-12-13 13:07

I\'m having an issue with my app when testing for iPhone X. I\'m not sure how to adjust this issue, as well as not make it an issue for non iPhone X sizes. This only seems t

20条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 13:51

    Create a separate file with the following code:

    extension UITabBar {
        override open func sizeThatFits(_ size: CGSize) -> CGSize {
            super.sizeThatFits(size)
            guard let window = UIApplication.shared.keyWindow else {
                return super.sizeThatFits(size)
            }
            var sizeThatFits = super.sizeThatFits(size)
            sizeThatFits.height = window.safeAreaInsets.bottom + 40
            return sizeThatFits
        }
    }
    

提交回复
热议问题