When you set a image for a uiimageview in storyboard or interface builder, it retains the shape of the original UIImageView, which means that the image itself is completely distorted.
To match the size of the UIImageView to its image, I have to manually enter in the size from the file inspector.
Is there a way that UIImageView can automatically detect the native size of its image and size its self accordingly?
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 Image
UIImage *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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With