2

我正在使用 CIFilter 向图像添加过滤器。过滤图像后的结果图像具有以下大小:CGRectMake(10, 10, 70, 70). 我无法将结果图像内容模式设置为ScaleAspectFill. 这是代码:

    filter2image.frame = CGRectMake(90, 10, 70, 70)
    let filter2data = CIFilter(name: "CIPhotoEffectChrome")
    filter2data.setValue(CIImage(image: imageView.image), forKey: kCIInputImageKey)
    self.filter2image.image = UIImage(CIImage: filter2data.outputImage)
    filter2image.contentMode = UIViewContentMode.ScaleAspectFill
4

1 回答 1

0

设置 contentMode 后尝试更改框架。像这样:

let filter2data = CIFilter(name: "CIPhotoEffectChrome")
filter2data.setValue(CIImage(image: imageView.image), forKey: kCIInputImageKey)
self.filter2image.image = UIImage(CIImage: filter2data.outputImage)
filter2image.contentMode = UIViewContentMode.ScaleAspectFill
filter2image.frame = CGRectMake(90, 10, 70, 70)
于 2015-05-14T17:10:44.363 回答