我认为我正在执行转换
originalTransform = self.appContainer.transform;
self.appContainer.transform = CGAffineTransformMakeScale(.8, .8);
如果我不旋转设备,我可以通过使用将其恢复到原来的状态
self.appContainer.transform = CGAffineTransformScale(originalTransform, 1, 1);
不幸的是,如果我旋转设备, View 的变换矩阵会被 View 旋转修改并破坏原始比例。如果我在旋转后撤消比例,我会看到 UIView
没有恢复到原来的完整大小。
我确定我需要在原始变换矩阵和新变换矩阵之间进行计算,但我不确定如何执行此操作。我唯一能做的就是在旋转之前将比例恢复为 1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
self.appContainer.transform = CGAffineTransformScale(originalTransform, 1, 1);
}
然后在
之后用新修改的变换重新缩放它-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
self.appContainer.transform = CGAffineTransformMakeScale(.8, .8);
}
这使它按我预期的方式工作,但我不想返回全屏,然后返回 .8 比例,我希望它从新转换到正确的 .8 比例。
最佳答案
如果您想将其恢复为原始状态,请尝试将转换设置为 CGAffineTransform Identity。
self.appContainer.transform = CGAffineTransformIdentity;
关于iphone - CGAffineTransform Scale 在设备旋转后修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10519735/