Reputation: 615
I have an image which I want to scale accordingly to a certain percentage which I have done this way:
CGRect frame = _image.frame;
frame.size.height = frame.size.height * 0.4 //0.4 is actually a float
_image.frame = frame;
This scales the image properly, although the origin is the center, so the image shrinks in to the middle. When I do the same thing in Interface Builder, I can set the origin to down in the middle and when I change the size of the height it shrinks perfectly only in length. How can I do that programmatically. I tried anchorPoint but that screws everything up, I don't know why.
Upvotes: 1
Views: 310
Reputation: 2768
set contentMode
property of UIImageView
with UIViewContentModeScaleAspectFit
or some other value, by Interface Builder
or program, to meet your scale style.
Upvotes: 2