(Material source code) Cat and cat learning IOS () core of UI animation two lines of code to deal with 3D transfer (android CRYING), iosandroid

Source: Internet
Author: User

(Material source code) Cat and cat learning IOS () core of UI animation two lines of code to deal with 3D transfer (android CRYING), iosandroid

CAT/CAT sharing, must be excellent

For Original Articles, please reprint them. Reprinted Please note: Yan Nai-yu's blog
Http://blog.csdn.net/u013357243? Viewmode = contents
Source Material address: http://download.csdn.net/detail/u013357243/8677065

Effect:

Code:
# Import "NYViewController. h "@ interface NYViewController () @ property (weak, nonatomic) IBOutlet UIImageView * iconView;-(IBAction) nextBtnClick :( id) sender;-(IBAction) preBtnClick :( id) sender; @ property (nonatomic, assign) int index; @ end @ implementation NYViewController // next-(IBAction) nextBtnClick :( id) sender {self. index ++; if (self. index> 7) {self. index = 1;} NSString * imageName = [NSString stringWithFormat: @ "mongod.jpg", self. index]; UIImage * newImage = [UIImage imageNamed: imageName]; self. iconView. image = newImage; // 1. create a core animation CATransition * ca = [CATransition animation]; // 1.1 animation transition type ca. type = @ "cube"; // 1.2 animation transition direction ca. subtype = kCATransitionFromRight; // 1.3 animation start point (percentage in the overall animation) // ca. startProgress = 0.5; // 1.3 animation end point (percentage in the overall animation) // ca. endProgress = 0.5; // animation time ca. duration = 1; // 2. add core animation [self. iconView. layer addAnimation: ca forKey: nil];} // The previous-(IBAction) preBtnClick :( id) sender {self. index --; if (self. index <1) {self. index = 7;} NSString * imageName = [NSString stringWithFormat: @ "mongod.jpg", self. index]; UIImage * newImage = [UIImage imageNamed: imageName]; self. iconView. image = newImage; // 1. create a core animation CATransition * ca = [CATransition animation]; // 1.1 tell the system what animation to execute ca. type = @ "cube"; ca. subtype = kCATransitionFromLeft; ca. duration = 1; // 2. add core animation [self. iconView. layer addAnimation: ca forKey: nil];} @ end

Related Article

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.