我在 UIImageWiew 中有一个带有其他 subview 的 UIScrollView,我需要旋转整个内容,所以我选择了这条路:
imageView.transform = CGAffineTransformMakeRotation([self.orientation floatValue]);
很好,完美运行。
作为 ScrollView 中的 ImageView,我还需要设置 zoomScale 以调整内部图像的大小,我是这样做的:
- (void)updateZoom {
const float minZoom = MIN(self.view.bounds.size.width / self.imageView.image.size.width,
self.view.bounds.size.height / self.imageView.image.size.height);
if (minZoom > 1) {
return;
}
self.scrollView.minimumZoomScale = minZoom;
self.scrollView.zoomScale = minZoom;
}
updateZoom 具有“重置”初始变换的效果,因此图像回到原始方向。 通常,每次我修改“zoomScale”属性时,方向都会恢复。
如何保持两个方向都缩放比例?
我想我需要在 scrollView 委托(delegate)中做一些事情:
- (void)scrollViewDidZoom:(UIScrollView *)scrollView;
最佳答案
我刚刚在 GitHub 上放了一个可能对您有帮助的存储库。它在 Swift 中,但它应该做
关于ios - 在 subview 中应用任何 "transform"后缩放 UIScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29671797/