我一直在尝试使用Swift 4填充XCode 9 iOS 11中的CAShapeLayer
颜色,但没有成功。
let circlePath = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: 12, startAngle: 0.0, endAngle: CGFloat(Double.pi * 2.0), clockwise: true)
let circleLayer = CAShapeLayer()
circleLayer.path = circlePath.cgPath
circleLayer.fillColor = UIColor.red.cgColor
circleLayer.strokeColor = UIColor.white.cgColor
circleLayer.lineWidth = 1.5
也许,你忘了设置一个框架。例如:
circleLayer.frame = CGRect(x: 6, y: 6, width: 12, height: 12)