SriPriya
SriPriya

Reputation: 1240

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.

Upvotes: 0

Views: 3034

Answers (1)

Ian L
Ian L

Reputation: 5601

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);
    }
}

Upvotes: 3

Related Questions