gpt4 book ai didi

iOS Swift - UIImageView 无法设置 ContentMode

转载 作者:搜寻专家 更新时间:2023-11-01 05:41:09 27 4
gpt4 key购买 nike

我正在使用 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

最佳答案

设置 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)

关于iOS Swift - UIImageView 无法设置 ContentMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30226404/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com