开发者

how to zoom in and zoom out an image on clicking button in iphone

开发者 https://www.devze.com 2023-02-12 08:56 出处:网络
I have image in a imageview which is placed in a scrollview., Zoom in and out are performedon pinches,

I have image in a imageview which is placed in a scrollview., Zoom in and out are performed on pinches,

now, i want to zoom in and out on clicking buttons placed for zoom in开发者_如何转开发 and zoom out.

how to do it? Is there any option? if anyone knows please tell me.

Thanks in advance.


You can set the zoom scale of the scroll view programatically based on the tap of a button. A simple implementation:

- (IBAction)zoomIn:(id)sender {
    if(scrollView.zoomScale < scrollView.maximumZoomScale) {
        scrollView.zoomScale = (scrollView.zoomScale + 0.1);
    }
}


- (IBAction)zoomOut:(id)sender {
    if(scrollView.zoomScale > scrollView.minimumZoomScale) {
        scrollView.zoomScale = (scrollView.zoomScale - 0.1);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消