more arrow

This commit is contained in:
Kevin G Christiano 2020-04-02 12:40:28 -04:00
parent bdda06629f
commit 3210f25cd5

View File

@ -106,27 +106,25 @@ open class Arrow: View {
arrowLayer.transform = CATransform3DIdentity arrowLayer.transform = CATransform3DIdentity
drawShapeLayer() drawShapeLayer()
if let degrees = arrowModel?.degrees { let radians = CGFloat(degrees * Float.pi / 180)
let radians = CGFloat(degrees * Float.pi / 180) arrowLayer.transform = CATransform3DMakeRotation(-radians, 0.0, 0.0, 1.0)
arrowLayer.transform = CATransform3DMakeRotation(-radians, 0.0, 0.0, 1.0)
}
} }
private func drawShapeLayer() { private func drawShapeLayer() {
arrowLayer.frame = bounds arrowLayer.frame = bounds
arrowLayer.strokeColor = isEnabled ? arrowModel?.color.cgColor : arrowModel?.disabledColor.cgColor arrowLayer.strokeColor = isEnabled ? color.cgColor : disabledColor.cgColor
arrowLayer.fillColor = UIColor.clear.cgColor arrowLayer.fillColor = UIColor.clear.cgColor
arrowLayer.path = arrowPath() arrowLayer.path = arrowPath()
arrowLayer.lineJoin = .miter arrowLayer.lineJoin = .miter
arrowLayer.lineCap = .butt arrowLayer.lineCap = .butt
arrowLayer.lineWidth = arrowModel?.lineWidth ?? 1 arrowLayer.lineWidth = lineWidth
} }
private func arrowPath() -> CGPath { private func arrowPath() -> CGPath {
let length = max(bounds.size.height, bounds.size.width) let length = max(bounds.size.height, bounds.size.width)
let inset = (arrowModel?.lineWidth ?? 1) / 2 let inset = lineWidth / 2
let midLength = length / 2 let midLength = length / 2
var startPoint = CGPoint(x: midLength, y: inset) var startPoint = CGPoint(x: midLength, y: inset)