[英]Using swift does iOS 13.4 have class CIVibrance or a string “CIVibrance” or the method CIFilter().vibrance()?
Looking for class CIVibrance or a string "CIVibrance" or the method like CIFilter().vibrance() in swift.在 swift 中寻找 class CIVibrance 或字符串“CIVibrance”或 CIFilter().vibrance() 之类的方法。 Looking at the docs some appear unavailable in swift but others are missing from Xcode.查看文档,有些文档在 swift 中似乎不可用,但 Xcode 中缺少其他文档。 (iOS 13.4 Xcode 11.5) (iOS 13.4 Xcode 11.5)
https://developer.apple.com/documentation/coreimage/cifilter/3228429-vibrance https://developer.apple.com/documentation/coreimage/civibrance?language=occ 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
}
}
You can press shift + command + o (the letter “oh”) or select “File” » “Open Quickly...” menu, and search for the method or class name:您可以按shift + command + o (字母“哦”)或 select “文件”»“快速打开...”菜单,然后搜索方法或 class 名称:
That will often give you a clue as to where it might be.这通常会给你一个关于它可能在哪里的线索。 In this case:在这种情况下:
import CoreImage.CIFilterBuiltins
For example:例如:
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) }
}
}
Yields:产量:
(with original image on left, vibrant rendition on right) (左边是原始图像,右边是生动的再现)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.