Search code examples
uiimageviewswiftrounded-cornersswift-playground

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


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


Solution

  • 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