(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