How do I make a UIImageView with rounded corners on a Swift iOS Playground?
Inside it needs to be filled with a color.
You can give it round corners by changing the cornerRadius property of the view's layer . and smaller values give less rounded corners. Both clipsToBounds and masksToBounds are equivalent.
Select the view that you want to round and open its Identity Inspector. In the User Defined Runtime Attributes section, add the following two entries: Key Path: layer. cornerRadius , Type: Number, Value: (whatever radius you want)
let imageView = UIImageView(frame: CGRectMake(0, 0, 100, 100)) imageView.backgroundColor = UIColor.redColor() imageView.layer.cornerRadius = 8.0 imageView.clipsToBounds = true
Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With