The two-finger zoom function can be implemented not only with Uipinchgesturerecognizer gestures, but also with Uiscorllview, Uiscrollview can easily achieve the maximum and minimum zoom values, as well as the effect of scrolling. The code is as follows:
#import "ViewController.h" @interface Viewcontroller () @property (weak, nonatomic) Iboutlet Uiscrollview *scrollview;@ Property (Strong, Nonatomic) Uiimageview *imageview; @end @implementation viewcontroller-(void) viewdidload { [ Super Viewdidload]; _scrollview.minimumzoomscale = 1.0; Minimum scaling value _scrollview.maximumzoomscale = 10.0; Maximum zoom value [_scrollview Setzoomscale:_scrollview.minimumzoomscale]; The initial zoom value _scrollview.delegate = self; _imageview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "image"]; _imageview.frame = Self.view.frame; [_scrollview Addsubview:_imageview];} #pragma mark-Returns the control that needs to be scaled-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) ScrollView { return _imageview;} -(void) didreceivememorywarning { [Super didreceivememorywarning];} @end
The key point is to callViewforzoominginscrollview:Proxy method, which returns the control that needs to be scaled.
Demo's github address: Https://github.com/are1/UIScrollViewZoomScale
iOS uses Uiscorllview to achieve two-finger zoom functions