开发者

UIImageView moves or resizes when I set the image

开发者 https://www.devze.com 2023-02-16 23:55 出处:网络
I created a UIImageView in interface builder. I retrieve an image via a urlrequest and then call se开发者_StackOverflow中文版tImage: with the UIImage. Unfortunately this causes the UIImageView to chan

I created a UIImageView in interface builder. I retrieve an image via a urlrequest and then call se开发者_StackOverflow中文版tImage: with the UIImage. Unfortunately this causes the UIImageView to change its position on the screen and frame size


I am assuming that the image that you are retrieving has a different size than that of the UIImageView.

Setting "Scale to fill" in IB will cause your image to stretch to fill completely you UIImageView, which depending on your content may not be desirable.

"Aspect fill" should fit and clip the image, but for this to work with images set programmatically, you must also check "clip subviews" in IB. If you don't your UIImage will overflow the bounds of the UIImageView.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号