iPhoneX横竖屏旋转适配

2018-03-12  本文已影响69人  xxxxxxxxx_ios

横竖屏幕适配

- (void)viewDidLayoutSubviews{

    [super viewDidLayoutSubviews];
    
    UIEdgeInsets safeAreaInsets = UIEdgeInsetsZero;
    if (@available(iOS 11.0, *)) {
        safeAreaInsets = self.view.safeAreaInsets;
    }
    
    self.viewTop.constant = safeAreaInsets.top;
    self.viewLeft.constant = safeAreaInsets.left;
    self.viewRight.constant = safeAreaInsets.right;
    self.viewBottom.constant = safeAreaInsets.bottom;
}

上一篇下一篇

猜你喜欢

热点阅读