How to draw a circle in Swift 3

霸气de小男生 提交于 2019-12-24 07:50:09

问题


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


回答1:


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! :)



来源:https://stackoverflow.com/questions/40555462/how-to-draw-a-circle-in-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!