Nikhil Sridhar
Nikhil Sridhar

Reputation: 1740

Changing Color of UIBezierPath in Swift

I was trying to change the color of a UIBezierPath so I copied some reliable code from the Internet, but I got an error which I can't seem to understand. Below is the code and the error. Please help.

 override func draw(_ rect: CGRect) {
    let skullRadius = min(bounds.width, bounds.height)
    let skullCenter = CGPoint(x: bounds.midX, y: bounds.midY)
    let skull = UIBezierPath(arcCenter: skullCenter, radius: skullRadius, startAngle: 0.0, endAngle: CGFloat(2*M_PI), clockwise: false)
    skull.lineWidth = 3
    UIColor.blueColor().setFill()
    skull.stroke()
}

enter image description here

Upvotes: 0

Views: 1919

Answers (1)

fzh
fzh

Reputation: 688

you should this code:

 override func draw(_ rect: CGRect) {
    let skullRadius = min(bounds.width, bounds.height)
    let skullCenter = CGPoint(x: bounds.midX, y: bounds.midY)
    let skull = UIBezierPath(arcCenter: skullCenter, radius: skullRadius, startAngle: 0.0, endAngle: CGFloat(2*M_PI), clockwise: false)
    skull.lineWidth = 3
    UIColor.blue.setFill()
    skull.stroke()
}

Upvotes: 1

Related Questions