|
//
// FFProgress.swift
// PaiAi
//
// Created by zhengjianfei on 2017/3/22.
// Copyright © 2017年 FFIB. All rights reserved.
//
import UIKit
class FFProgress: UIView {
@IBInspectable var lineColor = UIColor.red
@IBInspectable var lineWidth: CGFloat = 6
let progressLayer = CAShapeLayer()
var strokeEnd: CGFloat = 0.0 {
didSet {
progressLayer.strokeEnd = strokeEnd
}
}
override func draw(_ rect: CGRect) {
let bezierPath = UIBezierPath(arcCenter:CGPoint(x: self.width / 2, y: self.height / 2), radius: self.width / 2, startAngle: .pi / 180.0, endAngle: .pi / -2.0, clockwise: true)
progressLayer.frame = self.bounds
progressLayer.fillColor = UIColor.clear.cgColor
progressLayer.strokeColor = lineColor.cgColor
progressLayer.lineCap = kCALineCapRound
progressLayer.lineWidth = lineWidth
progressLayer.strokeEnd = strokeEnd
progressLayer.path = bezierPath.cgPath
self.layer.addSublayer(progressLayer)
}
}
|