changing the height of UITabBar in iOS7/8?

前端 未结 8 2071
轮回少年
轮回少年 2020-12-08 05:29

I am trying to change the height of the stock UITabBar to 44px, similar to Tweetbot\'s tab bar height. I\'ve also seen a few other apps do this as well.

8条回答
  •  眼角桃花
    2020-12-08 06:04

    If you are on iOS 11 then following will help

    -(CGSize)sizeThatFits:(CGSize)size
    {
        CGSize sizeThatFits = [super sizeThatFits:size];
        sizeThatFits.height = 60;
    
        if (@available(iOS 11.0, *)) {
            UIWindow *window = UIApplication.sharedApplication.keyWindow;
            CGFloat bottomPadding = window.safeAreaInsets.bottom;
            sizeThatFits.height += bottomPadding;
        }
    
        return sizeThatFits;
    }
    

    Basically need to cover safe area, else tabbar height on iPhone X appears to be low.

提交回复
热议问题