美文网首页
核心动画

核心动画

作者: Mr丶炎 | 来源:发表于2016-08-15 18:28 被阅读10次
动画类型.png
#import "ViewController.h"

@interface ViewController ()
{

  NSMutableArray *images;
  int index;
  
}

@property (strong, nonatomic) IBOutlet UIImageView *imageView;
@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  
  index = 0;
  
  images = [NSMutableArray arrayWithCapacity:6];
  
  for (int i =0; i<6; i++) {
    
    NSString *string = [NSString stringWithFormat:@"%d.jpg",i+1];
    UIImage *iamge = [UIImage imageNamed:string];
    
    [images addObject:iamge];
    
  }
  
  
  self.imageView.image = [UIImage imageNamed:@"1.jpg"];
  self.imageView.userInteractionEnabled = YES;//用户交互
  
  
  UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(changeImage)];
  swipe.direction = UISwipeGestureRecognizerDirectionLeft;
  
  [self.imageView addGestureRecognizer:swipe];
  
  
  
  
  
}

-(void)changeImage{
  index++;
  
  if (index>=6) {
    index =0;
    
  }
  
  self.imageView.image = [images objectAtIndex:index];
    
    //转场动画
    CATransition *trans = [[CATransition alloc]init];
    
    //属性
    //fade, `moveIn', `push' and `reveal
    trans.type = @"push";//动画类型
    
    trans.duration = 1;
    
    //动画过渡方向
    //fromLeft', `fromRight', `fromTop' and  fromBottom
    trans.subtype =@"fromLeft";
    
    
    
    [self.imageView.layer addAnimation:trans forKey:nil];
    
    
}

相关文章

  • IOS 核心动画CoreAniamation总结

    iOS 核心动画是基于CALayer层的动画,UIView动画是系统对核心动画的封装,核心动画相对UIView来说...

  • iOS基础 - 核心动画(转)

    iOS基础 - 核心动画 一、核心动画 l核心动画基本概念 l基本动画 l关键帧动画 l动画组 l转场动画 lCo...

  • iOS核心动画高级技巧 - 8

    iOS核心动画高级技巧 - 1iOS核心动画高级技巧 - 2iOS核心动画高级技巧 - 3iOS核心动画高级技巧 ...

  • iOS动画(Core Animation)

    1.核心动画(Core Animation):强大的动画API 核心动画所在的位置如下图 核心动画位于UIKit的...

  • IOS 常用动画的实现方式整理

    一、CoreAnimation(核心动画) 1.核心动画介绍 1.什么是核心动画 Core Animation可以...

  • UIview动画和核心动画的区别

    UIView和核心动画的区别 核心动画只能添加到CALayer,UIView没有办法使用核心动画 核心动画一切都是...

  • iOS-核心动画

    前言:核心动画的基础知识,包括基本动画、帧动画、转场动画相关知识。 一、核心动画(Core Animation) ...

  • iOS面试个人总结(1)

    动画 1.UIView动画与核心动画的区别? 核心动画只作用在layer. 核心动画修改的值都是假像.它的真实位置...

  • 再来看看动画

    动画一般有:UIKit动画和CoreAnimation(核心)动画 下面主要是核心动画的内容:http://www...

  • 一头扎进iOS核心动画(一)

    记录一下学习的笔记 核心动画 核心动画基本概念 基本动画 关键帧动画 动画组 转场动画 Core Animatio...

网友评论

      本文标题:核心动画

      本文链接:https://www.haomeiwen.com/subject/xpwusttx.html