Reputation: 5534
How can I get height for UIImageView based on fixed (310.0f) UIImageView width for real looking image ?
So the thing should work for placing UIImageViews in UITableViewCells (thats not important for question). But I want to point on some examples: 9gag app, facebook, google+ and other feeds with images that resize and are put in UITableViewCell
Upvotes: 2
Views: 1155
Reputation: 1152
Divide the width you want by the actual width of the image. Then multiple that number with the actual height.
UIImage* image = [UIImage imageNamed:@"someImage.png"];
CGSize imageSize = image.size;
CGFloat newHeight = (310.0 / imageSize.width) * imageSize.height;
Upvotes: 8