快速查找类CIVibrance或字符串“CIVibrance”或类似CIFilter()。vibrance()的方法。查看这些文档,其中一些似乎很快无法使用,但是其他一些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”)或选择“文件”»“快速打开...”菜单,然后搜索方法或类名:
这通常会为您提供可能的线索。在这种情况下:
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) }
}
}
产量:
(左侧为original image,右侧为生动的演绎)
关于ios - 使用swift,iOS 13.4是否具有类CIVibrance或字符串“CIVibrance”或方法CIFilter()。vibrance()?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62289753/