【发布时间】:2019-08-22 16:53:16
【问题描述】:
我想将视图框架更改为全屏边界并转换为横向。
我使用了 UIView 动画换帧和视图的变换。
- (void)enterFullScreen {
CGRect frame = CGRectMake(0, 0, CGRectGetHeight(UIScreen.mainScreen.bounds), CGRectGetWidth(UIScreen.mainScreen.bounds));
self.originFrame = self.presentView.frame;
[UIView animateWithDuration:ZXYAnimationDuration animations:^{
self.presentView.transform = CGAffineTransformMakeRotation(M_PI_2);
self.presentView.frame = frame;
} completion:^(BOOL finished) {
}];
}
- (void)exitFullScreen {
[UIView animateWithDuration:ZXYAnimationDuration animations:^{
self.presentView.transform = CGAffineTransformIdentity;
self.presentView.frame = self.originFrame;
} completion:^(BOOL finished) {
}];
}
【问题讨论】:
-
不要修改框架而是使用自动布局约束
-
我发现,不能同时修改trasnform和frame,如果我只修改frame或者transform就可以了。