Is there a way to auto-size a UIImageView in Interface Builder/storyboard? Is there a way to auto-size a UIImageView in Interface Builder/storyboard? xcode xcode

Is there a way to auto-size a UIImageView in Interface Builder/storyboard?


I am assuming you are referring to layout in storyboard/IB. To get the native size of the image just select the image and press Command + = on the keyboard. the to re-size it proportionally select the corner and hold down the shift key when you re-size it.


Why don't you set the size of your uiimageview in code?Here's what you need to do...

//get the ImageUIImage *img = [UIImage imageNamed:@"img.png"];CGFloat x = img.origin.x;CGFloat y = img.origin.y;CGFloat width = img.size.width;CGFloat height = img.size.height;imageView.frame = CGRectMake(x, y, width, height);  //imageView is your uiimageview's reference


Use the contentMode

 imageView.contentMode = UIViewContentModeScaleAspectFit;

Edit :I just saw you seem to want to adjust imageViews size to the image.... Different then