Merge branch 'develop' into feature/list_threecolumn_speedtest
This commit is contained in:
commit
e3e4f3c088
@ -19,8 +19,6 @@ import UIKit
|
|||||||
// MARK: setup
|
// MARK: setup
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
//avoid adding height constraint multiple times
|
|
||||||
guard heightConstraint == nil else { return }
|
|
||||||
heightConstraint = heightAnchor.constraint(equalToConstant: 0)
|
heightConstraint = heightAnchor.constraint(equalToConstant: 0)
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
||||||
@ -51,6 +49,31 @@ import UIKit
|
|||||||
}
|
}
|
||||||
heightConstraint?.constant = graphObject.diameter
|
heightConstraint?.constant = graphObject.diameter
|
||||||
|
|
||||||
|
// iOS 12 uses the conic gradient and a mask for simplicity.
|
||||||
|
if #available(iOS 12, *) {
|
||||||
|
let gradient = CAGradientLayer()
|
||||||
|
gradient.type = .conic
|
||||||
|
gradient.startPoint = CGPoint(x: 0.5, y: 0.5)
|
||||||
|
gradient.endPoint = CGPoint(x: 0.5, y: 0.0)
|
||||||
|
gradient.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter)
|
||||||
|
gradient.colors = graphObject.colors.map({ (color) -> CGColor in
|
||||||
|
return color.cgColor
|
||||||
|
})
|
||||||
|
gradientLayer = gradient
|
||||||
|
layer.addSublayer(gradient)
|
||||||
|
|
||||||
|
let center = CGPoint(x: gradient.bounds.midX, y: gradient.bounds.midY)
|
||||||
|
let radius = (graphObject.diameter - graphObject.lineWidth) / 2.0
|
||||||
|
let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: (3 / 2 * .pi), endAngle: -(1 / 2 * .pi), clockwise: false)
|
||||||
|
let mask = CAShapeLayer()
|
||||||
|
mask.fillColor = UIColor.clear.cgColor
|
||||||
|
mask.strokeColor = UIColor.white.cgColor
|
||||||
|
mask.lineWidth = graphObject.lineWidth
|
||||||
|
mask.path = path.cgPath
|
||||||
|
gradient.mask = mask
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//create circle path
|
//create circle path
|
||||||
let radius = graphObject.diameter / 2.0
|
let radius = graphObject.diameter / 2.0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user