smerTDima
smerTDima

Reputation: 41

How to draw a circle in Swift 3

Swift 3 How to make a circle? The circle should be located at the center. Was certain radius. The background - blackblur. Thank you

Upvotes: 1

Views: 10693

Answers (1)

Kevin Sabbe
Kevin Sabbe

Reputation: 1452

In order to make a circle draw a square and add a cornerRadius equal at width / 2:

let circle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0))

circle.center = self.view.center
circle.layer.cornerRadius = 50
circle.backgroundColor = UIColor.black
circle.clipsToBounds = true


var darkBlur = UIBlurEffect(style: UIBlurEffectStyle.dark)
var blurView = UIVisualEffectView(effect: darkBlur)

blurView.frame = circle.bounds

circle.addSubview(blurView)
self.view.addSubview(circle)

Good luck! :)

Upvotes: 10

Related Questions