开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜