我有一个包含视图的滚动视图。在视图中有3个imageViews(屏幕大小)。 用户可以随时站在第二个imageview上。 我想让用户缩放此图像视图。
如何正确实施缩放我的情况?
答案 0 :(得分:0)
请参阅本教程,希望有所帮助:)
答案 1 :(得分:0)
您可以将滚动视图设置为最大和最小缩放比例,如下所示..
在第二张图片的第二页上,只需将您的滚动视图设置为maximumzoomscale属性...
CGFloat minScale = MIN(yourScrollView.frame.size.width, yourScrollView.frame.size.height);
yourScrollView.minimumZoomScale = minScale;
yourScrollView.maximumZoomScale = 1.0f; /// set here your zoom scale...
yourScrollView.zoomScale = minScale;
<强>更新强>
// Get a zoom scale that's zoomed in slightly, capped at the maximum zoom scale specified by the scroll view
CGFloat newZoomScale = yourScrollView.zoomScale * 1.5f;
newZoomScale = MIN(newZoomScale, yourScrollView.maximumZoomScale);
// Figure out the rect we want to zoom to, then zoom to it
CGSize scrollViewSize = yourScrollView.bounds.size;
CGFloat w = scrollViewSize.width / newZoomScale;
CGFloat h = scrollViewSize.height / newZoomScale;
CGFloat x = yourScrollView.center.x - (w / 2.0f);
CGFloat y = yourScrollView.center.y - (h / 2.0f);
CGRect rectToZoomTo = CGRectMake(x, y, w, h);
[yourScrollView zoomToRect:rectToZoomTo animated:YES];
我希望这可以帮助你...