Catransform3d Animation Tutorial

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.