Ios CIImage filter正在垂直拉伸我的图像

Ios CIImage filter正在垂直拉伸我的图像,ios,cocoa-touch,ios6,uiimageview,core-image,Ios,Cocoa Touch,Ios6,Uiimageview,Core Image,我有一个在自定义UITableViewCell中使用的图像。图像是透明背景上的黑色三角形,我使用CIColorInvert过滤器使其成为透明背景上的白色三角形 过滤(反转)图像正在垂直拉伸,如何阻止这种情况发生 如果我直接加载UIImage,而不进行过滤,我得到的结果是: 如果我应用CIFilter我得到的是: 这是我的密码: // create the white triangle CIImage *inputImage = [[CIImage alloc] initWithImage:

我有一个在自定义
UITableViewCell
中使用的图像。图像是透明背景上的黑色三角形,我使用
CIColorInvert
过滤器使其成为透明背景上的白色三角形

过滤(反转)图像正在垂直拉伸,如何阻止这种情况发生

如果我直接加载
UIImage
,而不进行过滤,我得到的结果是:

如果我应用
CIFilter
我得到的是:

这是我的密码:

// create the white triangle
CIImage *inputImage = [[CIImage alloc] initWithImage:
                       [UIImage imageNamed:@"TriangleRight"]];

CIFilter *invertFilter = [CIFilter filterWithName:@"CIColorInvert"];
[invertFilter setDefaults];
[invertFilter setValue: inputImage forKey: @"inputImage"];

CIImage *outputImage = [invertFilter valueForKey: @"outputImage"];

CIContext *context = [CIContext contextWithOptions:nil];

rightArrow = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
在这两种情况下,我都在
UIImageView
中设置图像,如下所示:

cell.arrow.image = rightArrow;
UIImageView
尺寸为15x15(以磅为单位)。TrianglerRight.png为15x15像素,TriangleRight@2x.png是30x30像素

我缺少什么来防止
CIFilter
拉伸图像

更新: 发布问题5分钟后,我发现了问题:我使用的是自动布局,而
UIImageView
没有明确的高度限制(只有宽度)。添加显式高度约束解决了此问题。然而,这仍然不能解释为什么直接使用
UIImage
有效(即使没有明确的高度约束)

此外,使用原始方向应该已将其固定

UIImageOrientation originalOrientation = self->imageview.image.imageOrientation;
imageview.image = [[UIImage alloc] initWithCGImage:imgRef scale:1.0     orientation:originalOrientation];