解決iPhoneX push過程中tabbar上移的問題

自定義TabBar,繼承於UITabBar,重寫兩個方法,如下:

#import "CustomTabBar.h"


@implementation CustomTabBar


#pragma mark - Override Methods

- (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];

}


#pragma mark - Initial Methods

- (instancetype)initWithFrame:(CGRect)frame{

    

    self = [super initWithFrame:frame];

    if (self) {

        self.translucent = false;

        self.backgroundColor = [UIColor whiteColor];

    }

    return self;

}

@end


然後在添加TabBar的地方設置一下

[self setValue:[[CustomTabBar alloc]init]forKey:@"tabBar"];



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章