轉場動畫

  • (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];

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容