0

My parent view has rounded corners on all sides and I would like the child image view to have rounded corners on the right-top and right-bottom to fit inside the parent view. Swift documentation says masksToBounds will solve this, but it does not work for me. As seen in the photo, the right side of the photo is not rounded on the right side. Let me know if you would like to see more of my code, thank you.

Here is my code:

 bottomViewThumbnailImageView.translatesAutoresizingMaskIntoConstraints = false bottomViewThumbnailImageView.clipsToBounds = true bottomViewThumbnailImageView.layer.masksToBounds = true NSLayoutConstraint.activate([ bottomViewThumbnailImageView.topAnchor.constraint(equalTo: bottomView.topAnchor), bottomViewThumbnailImageView.bottomAnchor.constraint(equalTo: bottomView.bottomAnchor), bottomViewThumbnailImageView.trailingAnchor.constraint(equalTo: bottomView.trailingAnchor), bottomViewThumbnailImageView.heightAnchor.constraint(equalTo: bottomViewThumbnailImageView.widthAnchor), ]) 

enter image description here

2 Answers 2

1

Try giving this for your cell

layer.masksToBounds = true 
Sign up to request clarification or add additional context in comments.

Comments

1

The property should be set for the imageView parent as it will flow to it's childs , setting it to the imageView itself has no effect

parentImg.clipsToBounds = true 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.