0
如何滾動到x,y的比例不是1.0?UIScrollView setContentOffset with Scale
我以爲我所要做的就是多倍於規模。如果我在zoomScale爲1時滾動到100,100,當zoomScale爲.50時,是否應該將它轉換爲50,50?
如何滾動到x,y的比例不是1.0?UIScrollView setContentOffset with Scale
我以爲我所要做的就是多倍於規模。如果我在zoomScale爲1時滾動到100,100,當zoomScale爲.50時,是否應該將它轉換爲50,50?
不確定setContentOffset,但如果你不喜歡這樣無需進行轉換:
- (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];
}