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

Thomas picture Thomas · Aug 24, 2014 · Viewed 91.8k times · Source

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

Answer

Mundi picture Mundi · Aug 24, 2014
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