swift2.0学习笔记之实现图片变圆
来源:互联网 发布:如何做淘宝兼职 编辑:程序博客网 时间:2024/05/16 06:07
用swift开发音乐播放器时,有时为了图片的炫酷化,将图片变为圆形,并且旋转。
使用方法如下
1.自定义一个UIimageView
import UIKit
class myimage: UIImageView {
required init?(coder aDecoder:NSCoder) {
super.init(coder: aDecoder)
//允许圆角化
self.clipsToBounds=true
//圆角半径
self.layer.cornerRadius=self.frame.size.width/2.0
self.layer.borderWidth=4.0
self.layer.borderColor=UIColor(red:1.0, green: 1.0, blue:1.0, alpha: 0.7).CGColor
}
//旋转
func onRoation()
{
let animation=CABasicAnimation(keyPath:"transform.rotation")
animation.fromValue=0.0
animation.toValue=M_PI*2.0
animation.duration=20.0
animation.repeatCount=10000
self.layer.addAnimation(animation, forKey:nil)
}
}
2.将图片继承这个类
- swift2.0学习笔记之实现图片变圆
- swift2.0学习笔记之字符串遍历
- swift2.0学习笔记之网络请求
- swift2.0学习笔记之使用第三方库KGFloatingDrawer实现抽屉
- Swift2.0--文档学习笔记
- swift2.0 学习笔记One
- swift2.0 学习笔记Two
- swift2.0 学习笔记Three
- swift2.0 学习笔记four
- swift2.0 学习笔记five
- swift2.0 学习笔记six
- swift2.0 学习笔记seven
- swift2.0 学习笔记eight
- swift2.0 学习笔记nine
- swift2.0 学习笔记ten
- swift2.0 学习笔记Eleven
- swift2.0 学习笔记Twelve
- swift2.0 学习笔记Thirteen
- android获取string.xml的值
- 百度地图新版定位
- 浅谈算法和数据结构: 一 栈和队列
- git的使用
- $.merge()——JQuery
- swift2.0学习笔记之实现图片变圆
- 架构之路(二):性能
- android数据缓存
- 关于userInteractionEnabled的属性的理解
- 浅谈算法和数据结构: 三 合并排序
- String hql = "from SpQuestion as q where q.questionTitle like %?%";
- 浅谈算法和数据结构: 四 快速排序
- Android 强制结束第三方App进程探索
- LeetCode(23)Merge k Sorted Lists