1.1:开始就会触发
- (void)viewWillLayoutSubviews;
1.2:开始就会触发
- (void)viewDidLayoutSubviews;
1.3:设备旋转的时候会触发。在UIScreen的bounds和size(下面方法中的参数)。按照size为主。
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator;
- (void)viewWillLayoutSubviews;
方法:- (void)viewWillLayoutSubviews
{
[self shouldRotateToOrientation:(UIDeviceOrientation)[UIApplication sharedApplication].statusBarOrientation];
}
-(void)shouldRotateToOrientation:(UIDeviceOrientation)orientation
{
if (orientation == UIDeviceOrientationPortrait ||orientation ==
UIDeviceOrientationPortraitUpsideDown) { // 竖屏
} else { // 横屏
}
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
size
: 屏幕翻转后的新的尺寸;coordinator
: 屏幕翻转过程中的一些信息,比如翻转时间等;48 (OC) 适配iPad和iPhone、以及横竖屏适配。
原文:https://www.cnblogs.com/zyzmlc/p/9447898.html