【发布时间】:2016-09-01 12:10:42
【问题描述】:
我遇到了一个问题,我想以编程方式而不是通过触摸或手势来缩放滚动视图的一部分(矩形)。
CGRect cropRect = CGRectMake(xPos * [UIScreen mainScreen].nativeScale, yPos * [UIScreen mainScreen].nativeScale, width1 * [UIScreen mainScreen].nativeScale, height1 * [UIScreen mainScreen].nativeScale);
[self.scrlVPhoto zoomToRect:cropRect animated:YES];
我已经设置了委托,也实现了委托方法。
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)aScrollView {
return self.containerView;
}
self.containerView 是我要缩放的视图。
我已经尝试了所有方法,但我仍然对如何摆脱这种情况感到困惑。
请有人可以帮助我。任何帮助表示赞赏。
提前致谢。
【问题讨论】:
-
子类化滚动视图并在子类中实现zoomToRect。这可以帮助你timoliver.com.au/2012/01/14/zooming-to-a-point-in-uiscrollview
-
试试这个 scrollView.zoomScale = (scrollView.zoomScale + 0.1);
-
[self.scrlVPhoto setZoomScale:2 animated:true];不工作。
标签: ios objective-c uiscrollview zooming