Why page Push animation Tabbar moving up in the iPhone X

后端 未结 7 1484
不知归路
不知归路 2020-12-02 11:00

I build a app Demo, use hidesBottomBarWhenPushed hide Tabbar in Push Animation.

\"Page

B

7条回答
  •  盖世英雄少女心
    2020-12-02 11:24

    This is my way。 Declare a subclass of UITabBar, such as ActionTabBar

    swift 3,4

    class ActionTabBar: UITabBar {
    
        override var frame: CGRect {
            get {
                return super.frame
            }
            set {
                var tmp = newValue
                if let superview = self.superview, tmp.maxY != superview.frame.height {
                    tmp.origin.y = superview.frame.height - tmp.height
                }
                super.frame = tmp
            }
        }
    }
    

    Objective-C

    @implementation ActionTabbar
    
    - (void)setFrame:(CGRect)frame
    {
        if (self.superview && CGRectGetMaxY(self.superview.bounds) != CGRectGetMaxY(frame)) {
            frame.origin.y = CGRectGetHeight(self.superview.bounds) - CGRectGetHeight(frame);
        }
        [super setFrame:frame];
    }
    
    @end
    

提交回复
热议问题