UIScrollView setContentOffset with Scale
How do I scroll to x,y with a scale not to 1.0?
I thought all I had to do is multiple it by the scale. if I scroll to 100,100 when th开发者_运维百科e zoomScale is 1, should this be converted to 50,50 when the zoomScale is .50?
Not sure about setContentOffset but no conversion is necessary if you do it like this:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.rootView;
}
- (void)zoomToPointInRootView:(CGPoint)center atScale:(float)scale {
CGRect zoomRect;
zoomRect.size.height = [scrollView frame].size.height / scale;
zoomRect.size.width = [scrollView frame].size.width / scale;
zoomRect.origin.x = center.x - (zoomRect.size.width / 2.0);
zoomRect.origin.y = center.y - (zoomRect.size.height / 2.0);
[scrollView zoomToRect:zoomRect animated:NO];
}
精彩评论