Reputation: 4765
I predefined the image's size in attributes of 320 320[and gave it a aspect ratio constraint of 1:1
After I click the photo and select an image from the photo library:
What things should I be checking to make the photo stay in its 320 by 320 container?
Upvotes: 1
Views: 352
Reputation: 532
photo.contentMode = UIViewContentModeScaleAspectFill;
[photo setClipsToBounds:YES];
Upvotes: 1
Reputation: 7746
Say this
imagePickerController.allowsEditing = true
Then you will have the option to crop the image to have it fit
Upvotes: 0
Reputation: 7756
FYI, you don't really not both height/width and aspect ratio.
The two thing you will likely need to look at changing are the contentMode, and clipsToBounds
Upvotes: 0
Reputation: 2459
I think you should set the contentMode
of your UIImageView
to UIViewContentModeScaleAspectFit
.
You can do it in the code, or in Interface Builder (set the mode
to Aspect fit
):
If you want, you can read the Apple's doc: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/ (on Understanding How Images Are Scaled
)
Upvotes: 0
Reputation: 862
Try calling:
view.updateConstraintsIfNeeded()
after loading the image.
Upvotes: 0