简体   繁体   中英

UIImage bleeds out from UIImageView

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

But when I add the image, it bleeds through the UIImageView and its superviews. How can I restrict the rendering of the image so it is only shown within the bounds of the UIImageView and centered with respect to the UIImageView's center?

View hierarchy is as follows:

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 view size: 100x100 image size: 320x480

UIImageView上的clipsToBounds属性设置为YES

你试过-setClipsToBounds:是吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM