How do I make an UIImage/-View with rounded corners CGRect (Swift)

前端 未结 8 2511
你的背包
你的背包 2020-12-13 01:47

How do I make a UIImageView with rounded corners on a Swift iOS Playground?
Inside it needs to be filled with a color.

8条回答
  •  情歌与酒
    2020-12-13 02:11

    let imageView = UIImageView(frame: CGRectMake(0, 0, 100, 100))
    imageView.backgroundColor = UIColor.redColor()
    imageView.layer.cornerRadius = 8.0
    imageView.clipsToBounds = true
    

    Result:

    enter image description here

提交回复
热议问题