How to draw a simple rounded rect in swift (rounded corners)

前端 未结 6 2112
北海茫月
北海茫月 2020-12-25 14:39

I managed to draw a rect :-) But I don\'t know how to draw a rounded rect.

Can someone help me out with the following code how to round the rect?

let         


        
6条回答
  •  没有蜡笔的小新
    2020-12-25 15:16

    override func draw(_ rect: CGRect) {
    
        let bezierPath = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 40.0, height: 40.0), cornerRadius: 3.0)
        UIColor.yellow.setFill()
        bezierPath.fill()
    
    }
    

提交回复
热议问题