虽然我将 imageView 设置为 aspectFit,但似乎通过 CIImage 创建的图像总是会被缩放以填充。
通过 2 种方式加载图像的简单示例:
// 1. load directly via UIImage
UIImage *imageByUIImage = [UIImage imageNamed:@"Megan-Fox-Look.jpg"];
self.uiImageView.image = imageByUIImage;
// 2. load via CIImage
NSString *filePath =
[[NSBundle mainBundle] pathForResource:@"Megan-Fox-Look" ofType:@"jpg"];
CIImage *ciImage =
[CIImage imageWithContentsOfURL:[NSURL fileURLWithPath:filePath]];
UIImage *imageByCIImage = [UIImage imageWithCIImage:ciImage scale:1.f orientation:UIImageOrientationUp];
self.ciImageView.image = imageByCIImage;
2 个图像视图(uiImageView 和 ciImageView)具有相同的“aspectFit”属性和相同的尺寸约束(200x200)。但只有(1)正确显示图像,(2)拉伸图像。
有什么问题?谢谢你。
我通过 Xcode 6.2 创建我的项目