11

I have a UIImage that is much smaller than the UIImageView I am applying it too, I would like to know how to scale the UIImage to fit the width of the UIImageView but keep the width x height ratio of the original small image.

This is what my code looks like pre any sort of scaling

playerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 222.0, self.playerView.frame.size.width-20, 245.0)];
playerImageView.contentMode = UIViewContentModeBottom;
UIImage *placeholderImage = [UIImage imageNamed: @"placeHolderVault.png"];
[playerImageView setImage:placeholderImage];
halfer
  • 19,471
  • 17
  • 87
  • 173
HurkNburkS
  • 5,452
  • 19
  • 95
  • 181

1 Answers1

15

Use the proper contentMode.

playerImageView.contentMode = UIViewContentModeScaleAspectFit;
Mundi
  • 78,879
  • 17
  • 112
  • 137