CATransition类动画
来源:互联网 发布:打开db数据库 编辑:程序博客网 时间:2024/06/03 17:11
- - (void)leftClick {
- [UIView beginAnimations:nil context:nil];//display mode, slow at beginning and end[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画时间[UIView setAnimationDuration:1.0f];//使用当前正在运行的状态开始下一段动画[UIView setAnimationBeginsFromCurrentState:YES];//给视图添加过渡效果[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:imageView cache:YES];[UIView commitAnimations];}- (void)rightClick {[UIView beginAnimations:nil context:nil];//display mode, slow at beginning and end[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画时间[UIView setAnimationDuration:1.0f];//使用当前正在运行的状态开始下一段动画[UIView setAnimationBeginsFromCurrentState:YES];//给视图添加过渡效果[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:imageView cache:YES];[UIView commitAnimations];}- (void)upClick {[UIView beginAnimations:nil context:nil];//display mode, slow at beginning and end[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画时间[UIView setAnimationDuration:1.0f];//使用当前正在运行的状态开始下一段动画[UIView setAnimationBeginsFromCurrentState:YES];//给视图添加过渡效果[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:imageView cache:YES];[UIView commitAnimations];}- (void)downClick {[UIView beginAnimations:nil context:nil];//display mode, slow at beginning and end[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画时间[UIView setAnimationDuration:1.0f];//使用当前正在运行的状态开始下一段动画[UIView setAnimationBeginsFromCurrentState:YES];//给视图添加过渡效果[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:imageView cache:YES];[UIView commitAnimations];}/*CATransition的type属性1.#define定义的常量kCATransitionFade 交叉淡化过渡kCATransitionMoveIn 新视图移到旧视图上面kCATransitionPush 新视图把旧视图推出去kCATransitionReveal 将旧视图移开,显示下面的新视图2.用字符串表示pageCurl 向上翻一页pageUnCurl 向下翻一页rippleEffect 滴水效果suckEffect 收缩效果,如一块布被抽走cube 立方体效果oglFlip 上下翻转效果*/- (void)MyCAnimation1 {CATransition *animation = [CATransition animation];//动画时间animation.duration = 1.0f;//display mode, slow at beginning and endanimation.timingFunction = UIViewAnimationCurveEaseInOut;//过渡效果animation.type = kCATransitionMoveIn;//过渡方向animation.subtype = kCATransitionFromTop;//添加动画[imageView.layer addAnimation:animation forKey:nil];}- (void)MyCAnimation2 {CATransition *animation = [CATransition animation];//动画时间animation.duration = 1.0f;//display mode, slow at beginning and endanimation.timingFunction = UIViewAnimationCurveEaseInOut;//在动画执行完时是否被移除animation.removedOnCompletion = NO;//过渡效果animation.type = @"pageCurl";//过渡方向animation.subtype = kCATransitionFromRight;//暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果animation.fillMode = kCAFillModeForwards;//动画停止(在整体动画的百分比).animation.endProgress = 0.7;[imageView.layer addAnimation:animation forKey:nil];}- (void)MyCAnimation3 {CATransition *animation = [CATransition animation];//动画时间animation.duration = 1.0f;//display mode, slow at beginning and endanimation.timingFunction = UIViewAnimationCurveEaseInOut;//过渡效果animation.type = @"pageUnCurl";//过渡方向animation.subtype = kCATransitionFromRight;//暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果animation.fillMode = kCAFillModeBackwards;//动画开始(在整体动画的百分比).animation.startProgress = 0.3;[imageView.layer addAnimation:animation forKey:nil];}- (void)MyCAnimation4 {[NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(updateButterfly) userInfo:nil repeats:YES];}- (void)updateButterfly {butterflyView.animationDuration = 0.75f;[self.view addSubview:butterflyView];[butterflyView startAnimating];butterflyView.center = [butterflyView randomCenterInView:self.view withInset:10.0f];}CATransition比较强大,一般可以使用CATransition模拟UIView的动画。/* 过渡效果fade //交叉淡化过渡(不支持过渡方向)push //新视图把旧视图推出去moveIn //新视图移到旧视图上面reveal //将旧视图移开,显示下面的新视图cube //立方体翻滚效果oglFlip //上下左右翻转效果suckEffect //收缩效果,如一块布被抽走(不支持过渡方向)rippleEffect //滴水效果(不支持过渡方向)pageCurl //向上翻页效果pageUnCurl //向下翻页效果cameraIrisHollowOpen //相机镜头打开效果(不支持过渡方向)cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)*//* 过渡方向fromRight;fromLeft;fromTop;fromBottom;*/CATransition *animation = [CATransition animation];animation.delegate = self;animation.duration = 0.5f; //动画时长animation.timingFunction = UIViewAnimationCurveEaseInOut;animation.fillMode = kCAFillModeForwards;animation.type = @"cube"; //过度效果animation.subtype = @"formLeft"; //过渡方向animation.startProgress = 0.0 //动画开始起点(在整体动画的百分比)animation.endProgress = 1.0; //动画停止终点(在整体动画的百分比)animation.removedOnCompletion = NO;[self.view.layer addAnimation:animation forKey:@"animation"];
- http://www.2cto.com/kf/201309/244669.html
0 0
- CATransition类动画
- CATransition类动画
- CATransition 动画
- CATransition动画
- CATransition动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- iOS动画 CATransition动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- 基础知识之PHP缓存技术
- IDoc-变更自动运行-change pointer 。
- 让activity横竖屏切换不重新调用各个生命周期方法
- Inxi:获取Linux系统和硬件信息的神器
- 图片相关:bigmap工具类,实现压缩、异步、并发、缓存
- CATransition类动画
- GitHub上README.md教程
- mysql 基本命令
- hdu 迷宫城堡
- 第4周项目2 -建设“单链表”算法库
- Java内部类之静态内部类
- keepalived nopreempt 失效总结
- poj 2774 后缀数组(模板题)
- 如何设置USERENV('CLIENT_INFO')的值