博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CALayer CABasicAnimation 组动画的设置,设置动画不回到初始位置
阅读量:5225 次
发布时间:2019-06-14

本文共 3366 字,大约阅读时间需要 11 分钟。

1   //设置旋转 2         let rotationAnimation:CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") 3         //rotationAnimation.toValue = CGFloat(M_PI_2) * rotateCount 4         rotationAnimation.fromValue = CGFloat(M_PI_2) * rotateCount 5         rotationAnimation.toValue = CGFloat(M_PI_2) * (++rotateCount) 6         rotationAnimation.removedOnCompletion = false 7         rotationAnimation.fillMode = kCAFillModeForwards 8         //设置缩放 9         let scaleAnimation:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale")10         if self.rotateCount % 2 == 1 {11             scaleAnimation.fromValue = 1.012             scaleAnimation.toValue = 0.7513             scaleAnimation.duration = 1.0; 14             scaleAnimation.removedOnCompletion = false15             scaleAnimation.fillMode = kCAFillModeForwards //设置 动画不回到起始位置,这两个要一起设置。 16         }17         //设置动画组18         let animationGroup:CAAnimationGroup = CAAnimationGroup()19         animationGroup.duration = 1.020         animationGroup.repeatCount = 021         animationGroup.animations = [rotationAnimation,scaleAnimation]22         animationGroup.removedOnCompletion = false23         animationGroup.fillMode = kCAFillModeForwards24         //组编动画25         self.VIDEO.playerLayer.addAnimation(animationGroup, forKey: "animationGroup")

 设置视频player显示的比例按照视频本身比例显示

1   func rotateAction(){ 2         let rotationAnimation:CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") 3         rotationAnimation.fromValue = CGFloat(M_PI_2) * rotateCount 4         rotationAnimation.toValue = CGFloat(M_PI_2) * (++rotateCount) 5         let scaleAnimation:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale") 6         if self.rotateCount % 2 == 1 { 7             scaleAnimation.fromValue = 1.0 8             let boolCompare =  (self.cast.video_height / self.cast.video_width) >= 1 ? true : false 9             if self.isLive() {10                 if  boolCompare  {11                     scaleAnimation.toValue = (self.VIDEO.width) / (self.VIDEO.height)12                 } else {13                     scaleAnimation.toValue = (self.VIDEO.height) / (self.VIDEO.width)14                 }15             } else if !self.isIpadCompact(){16                 if  boolCompare  {17                     scaleAnimation.toValue = (self.VIDEO.width) / (self.VIDEO.height)18                 } else {19                     scaleAnimation.toValue = (self.VIDEO.height) / (self.VIDEO.width)20                 }21             } else {22                 var ratio = (self.VIDEO.height) / (self.VIDEO.width)23                 if ratio > 2 {24                     ratio = 1.825                 } else if ratio > 1 {26                     ratio = 1.6527                 }28                 scaleAnimation.toValue = ratio29             }30             scaleAnimation.duration = 0.2;31         }32         let animationGroup:CAAnimationGroup = CAAnimationGroup()33         animationGroup.duration = 0.234         animationGroup.repeatCount = 035         animationGroup.animations = [rotationAnimation,scaleAnimation]36         animationGroup.removedOnCompletion = false37         animationGroup.fillMode = kCAFillModeForwards38         self.VIDEO.playerLayer.addAnimation(animationGroup, forKey: "animationGroup")39     }

 

转载于:https://www.cnblogs.com/741162830qq/p/4935586.html

你可能感兴趣的文章
比callback更简洁的链式执行promise
查看>>
android permission
查看>>
【译】在Asp.Net中操作PDF - iTextSharp - 使用字体
查看>>
.net 文本框只允许输入XX,(正则表达式)
查看>>
[BSGS][哈希]luogu P3846 可爱的质数
查看>>
Python 第四十五章 MySQL 内容回顾
查看>>
iostat参数说明
查看>>
Python-Mac 安装 PyQt4
查看>>
实验2-2
查看>>
String,StringBuffer与StringBuilder的区别?? .
查看>>
MongoDB遇到的疑似数据丢失的问题。不要用InsertMany!
查看>>
session token两种登陆方式
查看>>
IntelliJ IDEA 12集成Tomcat 运行Web项目
查看>>
android smack MultiUserChat.getHostedRooms( NullPointerException)
查看>>
实用的VMware虚拟机使用技巧十一例
查看>>
监控工具之---Prometheus 安装详解(三)
查看>>
不错的MVC文章
查看>>
网络管理相关函数
查看>>
IOS Google语音识别更新啦!!!
查看>>
20190422 T-SQL 触发器
查看>>