首页 > 其他 > 详细

核心动画 - CATransition

时间:2016-04-25 16:28:37      阅读:207      评论:0      收藏:0      [点我收藏+]

一、转场代码

缺点,现在只有三张图片。当i = 4的时候,就没有图片在出现了。

static int i = 1;

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    NSString *imageN = [NSString stringWithFormat:@"%d",i];
    
    _imageV.image = [UIImage imageNamed:imageN];
    
    i++;
}

技术分享

 

二、修改动画

 // 转场代码
    if (i == 4) {
        i = 1;
    }
    // 加载图片名称
    NSString *imageN = [NSString stringWithFormat:@"%d",i];
    
    _imageView.image = [UIImage imageNamed:imageN];
    
    i++;

技术分享

 

三、添加转场动画

转场动画只能和转场代码 写在一个方法中。不能分开到两个代码中。

static int i = 1;

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    if (i == 4) {
        i = 1;
    }
    
    NSString *imageN = [NSString stringWithFormat:@"%d",i];
    
    _imageV.image = [UIImage imageNamed:imageN];
    
    i++;
    
    // 转场动画
    CATransition *anim = [CATransition animation];
    anim.type = @"cube";
    [_imageV.layer addAnimation:anim forKey:nil];
}

技术分享

 

四、有多少种动画

 anim.type = @"cube";

这行代码可以写成

技术分享

核心动画 - CATransition

原文:http://www.cnblogs.com/iOS363536404/p/5431346.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!