How can I set bottom insets globally for a bigger tabbar?

vrwim Source

I have an app that requires a bigger tabbar (height = 75), but when I change the height of the tabbar then the Safe Area insets don't change, so when I make constraints to the bottom margin, it does not work and my content is covered by my tabbar. Also, UITableViews don't set the correct insets, so they can't scroll to the bottom.

I set the height of my tabbar by adding this overrided func in my UITabBarController subclass:

override func viewWillLayoutSubviews() {

    var tabbarHeight: CGFloat = 75

    if #available(iOS 11.0, *) {
        if let window = UIApplication.shared.keyWindow {
            tabbarHeight += window.safeAreaInsets.bottom

    var tabFrame = tabBar.frame
    tabFrame.size.height = tabbarHeight
    tabFrame.origin.y = view.frame.size.height - tabbarHeight;
    tabBar.frame = tabFrame;

Is this the right way to do this? Is there a better way to do this?



comments powered by Disqus