UIImage exits UIImageView

I have a UIImage (size 320x480) that I want to display with a much smaller UIImageView (size: 100x100).

But when I add the image, it expires through the UIImageView and its supervisors. How can I limit the rendering of the image so that it only appears within the UIImageView and centered on the center of the UIImageView?

The hierarchical hierarchy looks like this:

view: (main view associated with UIViewController)
 -level_1 view (contentMode = UIViewContentModeScaleToFill)
 --level_2 view (contentMode = UIViewContentModeCenter)
 ---level_3 view (container for UIImageView, contentMode = UIViewContentModeCenter)
 -----UIImageView (contentMode = UIViewContentModeCenter)


level_3 Image size: 100x100 Image size: 320x480


source to share

2 answers

Have you tried -setClipsToBounds: YES?



set property to clipsToBounds

value UIImageView




All Articles