1
我无法使用swift填充路径三角形。 我用下面的代码来做一个笔划。如何使用Core图形快速填充三角形
let view = UIView(frame: CGRectMake(0, 0, 300, 300))
let shape = CAShapeLayer()
view.layer.addSublayer(shape)
shape.opacity = 0.5
shape.lineWidth = 2
shape.lineJoin = kCALineJoinMiter
shape.strokeColor = UIColor(hue: 0.786, saturation: 0.79, brightness: 0.53, alpha: 1.0).CGColor
shape.fillColor = UIColor(hue: 0.786, saturation: 0.15, brightness: 0.89, alpha: 1.0).CGColor
let context = UIGraphicsGetCurrentContext()
CGContextSetStrokeColorWithColor(context, shape.strokeColor);
CGContextSetLineWidth(context, shape.lineWidth);
CGContextMoveToPoint(context, 100, 100)
CGContextAddLineToPoint(context, 150, 150)
CGContextAddLineToPoint(context, 100, 200)
CGContextAddLineToPoint(context, 100, 100)
CGContextDrawPath(context, kCGPathStroke);
任何想法,用什么来填补shape.fillColor这个三角形?
很多很多的感谢... –