美文网首页
适配iPhoneX,支持横竖屏显示功能

适配iPhoneX,支持横竖屏显示功能

作者: KennyHito | 来源:发表于2017-12-07 15:50 被阅读39次
个人链接
微信公众号.jpg

横竖屏代码:
采用Masonry框架进行适配;

//为了适配横竖屏
float padding1 = HitoSafeAreaHeight;
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.mas_equalTo(self.view);
    make.left.mas_equalTo(self.view);
    make.right.mas_equalTo(self.view);
    make.bottom.mas_equalTo(self.view).offset(-padding1);
}];

适配iPhoneX:

//状态栏高度
#define HitoStatusHeight [UIApplication sharedApplication].statusBarFrame.size.height
//导航栏高度
#define HitoNavHeight 44
//顶部高度
#define HitoTopHeight (HitoStatusHeight+HitoNavHeight)
//iPhoneX安全区域高度
#define HitoSafeAreaHeight (HitoStatusHeight>20?34:0)
//底部高度
#define HitoBottomHeight (49+HitoSafeAreaHeight)

效果图:


Result.gif

代码下载:
https://github.com/NSLog-YuHaitao/iPhoneX

相关文章

网友评论

      本文标题:适配iPhoneX,支持横竖屏显示功能

      本文链接:https://www.haomeiwen.com/subject/dxodixtx.html