1 #import "NJViewController.h"2 3 @interfaceNjviewcontroller ()4@property (Weak, nonatomic) Iboutlet Uiimageview *IconView;5-(Ibaction) Nextbtnclick: (ID) sender;6-(Ibaction) Prebtnclick: (ID) sender;7 8@property (nonatomic, assign)intindex;9 @endTen One @implementationNjviewcontroller A - //Next One --(Ibaction) Nextbtnclick: (ID) Sender { theself.index++; - if(Self.index >7) { -Self.index =1; - } + -NSString *imagename = [NSString stringWithFormat:@"%d.jpg", Self.index]; +UIImage *newimage =[UIImage imagenamed:imagename]; ASelf.iconView.image =NewImage; at - //1. Create a core animation -Catransition *ca =[catransition animation]; - //1.1 Animation Transition Type -Ca.type =@"Cube"; - //1.2 Animation transition Direction inCa.subtype =Kcatransitionfromright; - //1.3 start of animation (percent in overall animation) to //ca.startprogress = 0.5; +Ca.endprogress =0.5; - the * //Animation Time $Ca.duration =1;Panax Notoginseng - //2. Add a core animation the [Self.iconView.layer ADDANIMATION:CA forkey:nil]; + } A the //the previous one +-(Ibaction) Prebtnclick: (ID) Sender { -self.index--; $ if(Self.index <1) { $Self.index =7; - } -NSString *imagename = [NSString stringWithFormat:@"%d.jpg", Self.index]; theUIImage *newimage =[UIImage imagenamed:imagename]; -Self.iconView.image =NewImage;Wuyi the //1. Create a core animation -Catransition *ca =[catransition animation]; Wu //1.1 Tell the system what animations to perform -Ca.type =@"Cube"; AboutCa.subtype =Kcatransitionfromleft; $ -Ca.duration =1; - - //2. Add a core animation A [Self.iconView.layer ADDANIMATION:CA forkey:nil]; + the } - @end
Animation of iOS Core animation