class ProgressVIEw: UIVIEw { // MARK:- 定义属性 var progress : CGfloat = 0 { dIDSet { setNeedsdisplay() } } // MARK:- 重写drawRect方法 overrIDe func drawRect(rect: CGRect) { super.drawRect(rect) // 获取参数 let center = CGPoint(x: rect.wIDth * 0.5,y: rect.height * 0.5) let radius = rect.wIDth * 0.5 - 3 let startAngle = CGfloat(-M_PI_2) let endAngle = CGfloat(2 * M_PI) * progress + startAngle // 创建贝塞尔曲线 let path = UIBezIErPath(arcCenter: center,radius: radius,startAngle: startAngle,endAngle: endAngle,clockwise: true) // 绘制一条中心点的线 path.addlinetoPoint(center) path.closePath() // 设置绘制的颜色 UIcolor(white: 1.0,Alpha: 0.4).setFill() // 开始绘制 path.fill() }}
progressVIEw.bounds = CGRect(x: 0,y: 0,wIDth: 50,height: 50) progressVIEw.center = CGPoint(x: UIScreen.mainScreen().bounds.wIDth * 0.5,y: UIScreen.mainScreen().bounds.height * 0.5) // 3.设置控件的属性 progressVIEw.hIDden = true progressVIEw.backgroundcolor = UIcolor.clearcolor()
// 4.设置imagVIEw的图片 progressVIEw.hIDden = false imageVIEw.sd_setimageWithURL(getBigURL(picURL),placeholderImage: image,options: [],progress: { (current,total) -> VoID in self.progressVIEw.progress = CGfloat(current) / CGfloat(total) }) { (_,_,_) -> VoID in self.progressVIEw.hIDden = true }总结
以上是内存溢出为你收集整理的swift 绘制下载进度全部内容,希望文章能够帮你解决swift 绘制下载进度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)