smerTDima smerTDima - 27 days ago 15
Swift Question

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

Answer

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

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

blurView.frame = circle.bounds

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

Good luck! :)