Κυριακή, 12 Μαΐου 2013

how to zoom a uiimage


  1. create a UIScrollView, set delegate of here
  2. put the UIImage inside the UIScrollView
  3. at .h file conform the UIScrollViewDelegate
  4. at .m file
  1. - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
    {
        return self.imageView;
    }



Basic Zooming Using the Pinch Gestures

UIScrollView makes supporting the pinch gestures for zooming easy. Your application specifies the zoom factors (that is how much bigger or smaller you can make the content) and you implement a single delegate method. Taking those few steps allows your scroll view to support the pinch gestures for zooming.

Supporting the Pinch Zoom Gestures

The pinch-in and pinch-out zoom gestures are standard gestures that iOS application users expect to use when zooming in and out. Figure 3-1 shows examples of the pinch gestures.
Figure 3-1  The standard pinch-in and pinch-out gestures
To support zooming, you must set a delegate for your scroll view. The delegate object must conform to the UIScrollViewDelegate protocol. In many cases, the delegate will be the scroll view’s controller class. That delegate class must implement the viewForZoomingInScrollView: method and return the view to zoom. The implementation of the delegate method shown below returns the value of the controller’s imageView property, which is an instance of UIImageView. This specifies that the imageView property will be zoomed in response to zoom gestures, as well as any programmatic zooming.
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.imageView;
}
To specify the amount the user can zoom, you set the values of the minimumZoomScale and maximumZoomScale properties, both of which are initially set to 1.0. The value of these properties can be set in Interface Builder’s UIScrollView inspector panel, or programmatically. Listing 3-1 shows the code required in a subclass of UIVie

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου