ios – 按宽度按比例调整UIImage的大小
发布时间:2020-12-14 17:13:05 所属栏目:百科 来源:网络整理
导读:我需要按宽度按比例调整UI Image,可能有人有工作代码吗? 例如: Input: Width: 900 Height: 675. Resize to width: 400 width Result: Width: 400 Height: 300 请帮忙.. 解决方法 检查 this blog post.特别是这两个文件: UIImage+Resize.h UIImage+Resize.
我需要按宽度按比例调整UI
Image,可能有人有工作代码吗?
例如:
请帮忙.. 解决方法
检查
this blog post.特别是这两个文件:
> UIImage+Resize.h 也许这对你有用: 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]; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |