ios11 适配

1. 尺寸变化

//判断是否iPhone X

#define IS_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125,2436), [[UIScreen mainScreen] currentMode].size) : NO)


#define  StatusBarHeight      (IS_iPhoneX ? 44.f :20.f)


#define  TabbarHeight        (IS_iPhoneX ? (49.f+34.f) :49.f)


#define  StatusBarAndNavigationBarHeight  (IS_iPhoneX ? 88.f : 64.f)


#define  TabbarSafeBottomMargin        (IS_iPhoneX ? 34.f : 0.f)



2. 使用tableView在push之后偏移

    //判断iOS版本

    if (@available(iOS11.0, *)) {

        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用

    }else {

        self.automaticallyAdjustsScrollViewInsets =false;

    }


3. 隐藏导航栏左侧返回

 if (@available(iOS11.0, *)) {

       [[UIBarButtonItemappearance]setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColorclearColor]}forState:UIControlStateNormal];

        

    }else {

        [[UIBarButtonItemappearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)forBarMetrics:UIBarMetricsDefault];

    }



你可能感兴趣的:(IOS,适配)