美文网首页
转场动画

转场动画

作者: Fun箱Dao柜 | 来源:发表于2016-07-10 23:06 被阅读30次
    • (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //添加转场动画
    CATransition *anim = [CATransition animation];
    
    anim.duration = 1;
    
    //设置转场类型
    //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
    anim.type = @"oglFlip";
    anim.subtype = @"fromRight";
    [self.imageV.layer addAnimation:anim forKey:@"kCTransitionAnimation"];
    
    
    //转场代码 跟转场动画必须得要在同一个方法当中
    _i++;
    
    if (_i > 3) {
        _i = 1;
    }
    
    NSString *imageName = [NSString stringWithFormat:@"%d",_i];
    self.imageV.image = [UIImage imageNamed:imageName];
    

    // UIView *view = [[UIView alloc]init];
    // [view.layer addAnimation:anim forKey:nil];
    // self.imageV.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1];

    }

    相关文章

      网友评论

          本文标题:转场动画

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