@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *aniMationView;
@property(nonatomic,assign)int index;
- (IBAction)nextImageViewButn:(id)sender;
- (IBAction)lastiamgeViewbutn:(id)sender;
@end
- (IBAction)nextImageViewButn:(id)sender {
self.index ++;
if (self.index > 7) {
self.index = 1;
}
NSString * imageName = [NSString stringWithFormat:@"%d.JPG",self.index];
UIImage * image = [UIImage imageNamed:imageName];
self.aniMationView.image = image;
NSLog(@"下一张%d",self.index);
/** types的类型
@"rippleEffect":水滴效果,
@"suckEffect":收缩效果,像一块布被抽走,
@"cube":立方体翻转效果,
@"oglFlip":上下左右翻转效果
@"pageCurl":向上翻页效果
@"pageUnCul"向下翻页效果
@"cameraIrisHollowColse"相机镜头关上效果
@"cameraIrisHollowOpen"相机镜头打开效果
*/
/* Common transition types的类型. */
CA_EXTERN NSString * const kCATransitionFade
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CA_EXTERN NSString * const kCATransitionMoveIn
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CA_EXTERN NSString * const kCATransitionPush
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CA_EXTERN NSString * const kCATransitionReveal
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
/* Common transition subtypes的类型. */
CA_EXTERN NSString * const kCATransitionFromRight
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CA_EXTERN NSString * const kCATransitionFromLeft
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CA_EXTERN NSString * const kCATransitionFromTop
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CA_EXTERN NSString * const kCATransitionFromBottom
__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0);
CATransition * ca = [CATransition animation];
ca.type = @"rippleEffect";//水滴效果
ca.subtype = kCATransitionFromRight;
ca.duration = 0.5;//动画时长
[self.aniMationView.layer addAnimation:ca forKey:nil];
}
- (IBAction)lastiamgeViewbutn:(id)sender {
self.index--;
if (self.index < 1) {
self.index = 7;
}
NSString * imageName = [NSString stringWithFormat:@"%d.JPG",self.index];
UIImage * image = [UIImage imageNamed:imageName];
self.aniMationView.image = image;
NSLog(@"上一张%d",self.index);
CATransition * ca = [CATransition animation];
ca.type = kCATransitionPush;
ca.subtype = kCATransitionFromRight;
ca.duration = 0.5;
[self.aniMationView.layer addAnimation:ca forKey:nil];
}
部分动画效果图
网友评论