我需要按宽度按比例调整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.m
也许这对你有用:
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];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。