iOS实现音乐播放器图片旋转示例-创新互联

今天就跟大家聊聊有关iOS实现音乐播放器图片旋转示例,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

创新互联是一家专业提供安国企业网站建设,专注与成都做网站、网站设计、外贸营销网站建设HTML5建站、小程序制作等业务。10年已为安国众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

通过给继承与 UIImageView 的类 CXGImageView 添加 CABasicAnimation 转动动画,实现播放器图片转动效果.

主要提供三个方法: startRotating, stopRotating,resumeRotate

startRotating

/// 开始动画
func startRotating() {
 let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
 rotateAnimation.isRemovedOnCompletion = false // 避免点击 Home 键返回,动画停止
 rotateAnimation.fromValue = 0.0
 rotateAnimation.toValue = Double.pi * 2
 rotateAnimation.duration = 20
 rotateAnimation.repeatCount = MAXFLOAT
 self.layer.add(rotateAnimation, forKey: nil)
 isRotating = true
}

当前名称:iOS实现音乐播放器图片旋转示例-创新互联
转载来源:http://pwwzsj.com/article/dogpdh.html