gpt4 book ai didi

ios - 使用 swift iOS 13.4 是否有类 CIVibrance 或字符串 "CIVibrance"或方法 CIFilter().vibrance()?

转载 作者:行者123 更新时间:2023-12-01 21:45:22 26 4
gpt4 key购买 nike

快速查找 CIVibrance 类或字符串“CIVibrance”或 CIFilter().vibrance() 之类的方法。查看文档,有些文档在 swift 中似乎不可用,但 Xcode 中缺少其他文档。 (iOS 13.4 Xcode 11.5)

https://developer.apple.com/documentation/coreimage/cifilter/3228429-vibrance
https://developer.apple.com/documentation/coreimage/civibrance?language=occ

import UIKit
import CoreImage

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

func test() {
let ciFilter = CIFilter()

let ciVibrance = ciFilter.vibrance() // error
let ciVibrance2 = CIFilter.vibrance() // error
let ciVibrance3 = CIVibrance() // error
}
}

最佳答案

您可以按 shift+command+o(字母“oh”)或选择"file"»“快速打开...”菜单,然后搜索方法或类名:

enter image description here

这通常会给你一个关于它可能在哪里的线索。在这种情况下:

import CoreImage.CIFilterBuiltins

例如:
import UIKit
import CoreImage.CIFilterBuiltins

class ViewController: UIViewController {
@IBOutlet weak var imageView1: UIImageView!
@IBOutlet weak var imageView2: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()

imageView2.image = vibrantImage()
}

func vibrantImage() -> UIImage? {
guard let input = UIImage(named: "flower.jpg")?.cgImage else {
return nil
}

let filter = CIFilter.vibrance()
filter.amount = 1
filter.inputImage = CIImage(cgImage: input)
return filter.outputImage.flatMap { UIImage(ciImage: $0) }
}
}

产量:

enter image description here

(左边是 original image,右边是生动的演绎)

关于ios - 使用 swift iOS 13.4 是否有类 CIVibrance 或字符串 "CIVibrance"或方法 CIFilter().vibrance()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62289753/

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