参见英文答案 >
Resize UIImage by keeping Aspect ratio and width12个
我有一个比UIImageView小的UIImage,我也应用它,我想知道如何扩展UIImage以适应UIImageView的宽度,但保持原始小图像的宽x高比.
我有一个比UIImageView小的UIImage,我也应用它,我想知道如何扩展UIImage以适应UIImageView的宽度,但保持原始小图像的宽x高比.
这是我的代码看起来像任何类型的缩放
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];
任何帮助将不胜感激.
解决方法
使用正确的contentMode.
playerImageView.contentMode = UIViewContentModeScaleAspectFit;