我需要UIImage按宽度按比例调整大小,可能有人有工作代码吗?
例如:
输入:宽度:900高度:675.调整宽度:400宽度
结果:宽度:400高度:300
请帮忙..
查看此博客文章.特别是这两个文件:
也许这对你有用:
UIImage *image = [UIImage imageNamed:@"SomeImage-900x675"]; // SomeImage-900x675.png
CGFloat targetWidth = 400.0f;
CGFloat scaleFactor = targetWidth / image.size.width;
CGFloat targetHeight = image.size.height * scaleFactor;
CGSize targetSize = CGSizeMake(targetWidth, targetHeight);
UIImage *scaledImage = [image resizedImage:targetSize interpolationQuality:kCGInterpolationHigh];
| 归档时间: | 
 | 
| 查看次数: | 3623 次 | 
| 最近记录: |