我必须像照片应用程序一样实现旋转工作。将 UIImageView
放在 UIScrollView
中。当设备旋转时,我希望图像像照片一样旋转为横向。如果图像是横向的,那么它将用旋转动画填充整个 UIScrollView
的宽度。当下面的代码
[UIView animateWithDuration:0.36
animations:^(void){
[_imageView setTransform:CGAffineTransformMakeRotation(M_PI*90/180)];
_imageView.frame = CGRectMake(0, 0, 480, 320); //set the frame after the rotate
self.contentSize = CGSizeMake(480, 320); //set the content-size of the scrollview
}
completion:^(BOOL complete){
}];
但这不起作用。发生旋转,但_imageView
的位置不正确,或者图像没有填充宽度。即使我在转换之前更改了顺序框架和内容大小,仍然不正确。
实现此目的的正确方法是什么?
最佳答案
WWDC 2010 Video: Designing Apps with Scrolls Views向您展示具体如何执行此操作。
关于ios - 在 UIScrollView 内旋转 UIImageView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12777688/