Theoretical knowledge online too much, and now directly cast a effect ~ please all the way the big God pointing ~
Drag effect
#defineAppwith [UIScreen mainscreen].bounds.size.width#defineappheight [UIScreen mainscreen].bounds.size.height#import "ViewController.h"@interfaceViewcontroller () {Uiimageview*_IMAGEBG;}@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; _IMAGEBG= [[Uiimageview alloc]initwithframe:cgrectmake ( -, -, Max, -)]; _imagebg.image= [UIImage imagenamed:@"11.jpg"]; _imagebg.layer.cornerradius=5.0f; _imagebg.clipstobounds=YES; [Self.view ADDSUBVIEW:_IMAGEBG]; Uipangesturerecognizer*pan =[[Uipangesturerecognizer alloc]initwithtarget:self Action: @selector (Imageactionwithpan:)]; [Self.view Addgesturerecognizer:pan]; _imagebg.userinteractionenabled=YES;}- (void) Imageactionwithpan: (Uipangesturerecognizer *) pan{Cgpoint Point=[Pan LocationInView:self.view]; if(Pan.state = =uigesturerecognizerstatechanged) {cgfloat xx= MIN (0.1, MAX (-0.1, (Point.x-(appwith/2))/(appwith/2))); CGFloat yy= MIN (0.1, MAX (-0.1, (Point.y-(appheight/2))/(appheight/2))); _imagebg.layer.transform= [Self transform3dreturnm34: (-1/500.0) xx:xx Yy:yy]; } //Recovery if(Pan.state = =uigesturerecognizerstateended) {[UIView animatewithduration:0.5animations:^{_imagebg.layer.transform=catransform3didentity; }]; }}-(Catransform3d) Transform3dreturnm34: (cgfloat) M34 xx: (cgfloat) xx yy: (cgfloat) yy{Catransform3d Trans=catransform3didentity; TRANS.M34=M34; Trans= Catransform3drotate (trans, m_pi * xx,0,1,0); Trans= Catransform3drotate (trans, M_pi * yy,-1,0,0); returnTrans;}@end
Catransform3d Animation Tutorial