Swift2.3:
//创建旋转动画
let anim = CABasicAnimation(keyPath: "transform.rotation")
//旋转角度
anim.toValue = 1 * M_PI
//旋转指定角度需要的时间
anim.duration = 1
//旋转重复次数
anim.repeatCount = MAXFLOAT
//动画执行完后不移除
anim.removedOnCompletion = true
//将动画添加到视图的laye上
view.layer.addAnimation(anim, forKey: nil)
//取消动画
view.layer.removeAllAnimations()
//这个是旋转方向的动画
UIView.animateWithDuration(0.2) { () -> Void in
//指定旋转角度是180°
view.transform = CGAffineTransformRotate(view.transform, CGFloat(M_PI))
} Swift3.0:
let anim = CABasicAnimation(keyPath: "transform.rotation")
anim.toValue = 1 * M_PI
anim.duration = 1
anim.repeatCount = MAXFLOAT
anim.isRemovedOnCompletion = true
view1.layer.add(anim, forKey: nil)
view1.layer.removeAllAnimations()
UIView.animate(withDuration: 0.2) {
view1.transform = view1.transform.rotated(by: CGFloat(M_PI))
}

最新文章

  1. MongoDB-基础-limit-skip-sort
  2. STL set 用法
  3. 【笔记】js Function类型 内部方法callee
  4. Linux下多路径multipath配置
  5. [BZOJ4530][Bjoi2014]大融合 LCT + 启发式合并
  6. typedef和#define
  7. 非常实用的10个PHP高级应用技巧
  8. [POJ1236]Network of Schools(并查集+floyd,伪强连通分量)
  9. (转载)PHP去掉转义后字符串中的反斜杠\函数stripslashes
  10. 使用WMI控制Windows进程 和服务
  11. Python网络02 Python服务器进化
  12. mysql函数二
  13. linux查看系统负载
  14. IOS 看懂此文,你的block再也不需要WeakSelf弱引用了!
  15. Python“函数式编程”中常用的函数
  16. Python importlib 动态加载模块
  17. noip第18课资料
  18. NSArray与NSString、NSData,NSDictionary与NSString、NSData 相互转化
  19. docker 安全性问题
  20. 构建NDK交叉编译链

热门文章

  1. lastb---显示用户错误的登录列表
  2. kill&&pkill&&killall---删除执行中的程序
  3. git- 仓库创建、修改、提交、撤销
  4. dom4j解析xml文件和字符串
  5. HttpClient的基本使用
  6. ontouch、dispatchtouchevent、interceptouchevent-相关事件
  7. Docker安装RabbitMQ,RabbitMQ Management使用
  8. Invalid property 'annotatedClasses' of bean class
  9. 解决Keystore was tampered with, or password was incorrect
  10. Dynamics CRM2016 Web API之Expand related entities & $ref & $count