国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Swift > 正文

swift實現自定義圓環進度提示效果

2020-03-09 17:48:38
字體:
來源:轉載
供稿:網友
這篇文章主要為大家詳細介紹了swift實現自定義圓環進度提示效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
 

本文實例為大家分享了swift圓環進度提示效果的實現代碼,供大家參考,具體內容如下

效果圖:

swift,圓環進度

實現代碼:

/// ViewController.swift// PureSwiftAuto//// Created by 王木木 on 16/5/17.// Copyright © 2016年 王木木. All rights reserved.// import UIKit class ViewController: UIViewController {     let cireView = cireview.newAutoLayoutView()     override func viewDidLoad() {    super.viewDidLoad()    // Do any additional setup after loading the view, typically from a nib.    creatCire()  }     func creatCire(){    self.view.addSubview(cireView)    self.cireView.value = 2    self.cireView.maximumValue = 100    self.cireView.backgroundColor = UIColor.yellowColor()    self.cireView.frame = CGRectMake(100, 100, 100, 100)    wangmumu()  }     func wangmumu(){         self.cireView.value += 2         if self.cireView.value == 90 {return}         self.performSelector("wangmumu", withObject: self, afterDelay: 0.2)       }   }  class cireview: UIView{     var value: CGFloat = 0 {    didSet {      self.setNeedsDisplay()    }  }     var maximumValue: CGFloat = 0 {    didSet { self.setNeedsDisplay() }  }  override init(frame: CGRect) {    super.init(frame: frame)    self.opaque = false  }        override func drawRect(rect: CGRect) {    super.drawRect(rect)         //線寬度    let lineWidth: CGFloat = 10.0    //半徑    let radius = CGRectGetWidth(rect) / 2.0 - lineWidth    //中心點x    let centerX = CGRectGetMidX(rect)    //中心點y    let centerY = CGRectGetMidY(rect)    //弧度起點    let startAngle = CGFloat(-90 * M_PI / 180)    //弧度終點    let endAngle = CGFloat(((self.value / self.maximumValue) * 360 - 90) ) * CGFloat(M_PI) / 180         //創建一個畫布    let context = UIGraphicsGetCurrentContext()         //畫筆顏色    CGContextSetStrokeColorWithColor(context, UIColor.blueColor().CGColor)         //畫筆寬度    CGContextSetLineWidth(context, lineWidth)         //(1)畫布 (2)中心點x(3)中心點y(4)圓弧起點(5)圓弧結束點(6) 0順時針 1逆時針    CGContextAddArc(context, centerX, centerY, radius, startAngle, endAngle, 0)         //繪制路徑    CGContextStrokePath(context)         //畫筆顏色    CGContextSetStrokeColorWithColor(context, UIColor.darkGrayColor().CGColor)         //(1)畫布 (2)中心點x(3)中心點y(4)圓弧起點(5)圓弧結束點(6) 0順時針 1逆時針    CGContextAddArc(context, centerX, centerY, radius, startAngle, endAngle, 1)         //繪制路徑    CGContextStrokePath(context)       }     required init?(coder aDecoder: NSCoder) {    fatalError("init(coder:) has not been implemented")  }   }

以上就是本文的全部內容,希望對大家的學習有所幫助。



注:相關教程知識閱讀請移步到swift教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 洪湖市| 库伦旗| 凌海市| 莎车县| 怀来县| 永平县| 浦东新区| 丰宁| 太和县| 喜德县| 黔南| 敦化市| 东乡族自治县| 遵义县| 永济市| 郎溪县| 山东省| 龙口市| 周至县| 突泉县| 怀化市| 射阳县| 鱼台县| 香港 | 长寿区| 鄂托克旗| 舞阳县| 定安县| 西城区| 揭东县| 子洲县| 安新县| 临清市| 周至县| 衡阳市| 永丰县| 辽中县| 商南县| 合作市| 平原县| 莲花县|