我的觀點是複製許多使用照片的應用程序的行爲,其中UIScrollView
與UIImageView
內部正在呈現它適合圖像的大小,即使此圖像較小。設置UIScrollView縮放比例以適合屏幕
我敢肯定,這不應該與UIImageView
框架,但UIScrollView
操縱,但如何......?
在我的代碼我有一個名爲updateZoom
方法,其計算minimumZoomScale
值,也將此值賦給了zoomScale
財產。我想這是做數學計算的好地方,並且手動計算zoomScale
。
這是方法:
- (void)updateZoom {
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) {
minZoom = 1;
}
self.scrollView.minimumZoomScale = minZoom;
self.scrollView.zoomScale = minZoom;
}
我希望有人能給我一擊上如何設置zoomScale
以適應UIScrollView
界限。