I created a UIImageView in interface builder. I retrieve an image via a urlrequest and then call setImage: with the UIImage. Unfortunately this causes the UIImageView to change its position on the screen and frame size
Ios – UIImageView moves or resizes when I set the image
cocoa-touchiosuiimageview
Related Topic
- Ios – How to make a UITextField move up when the keyboard is present – on starting to edit
- Ios – Loaded nib but the ‘view’ outlet was not set
- Ios – Should IBOutlets be strong or weak under ARC
- Ios – How to animate constraint changes
- Ios – UIScrollView Scrollable Content Size Ambiguity
- Ios – How to change image tintColor in iOS and WatchKit
- Ios – UIImageView get the position of the showing Image
- Ios – UIImageView missing images in Launch Screen on device
Best Answer
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.