使用 swift iOS 13.4 是否具有 class CIVibrance 或字符串 "CIVibrance" 或方法 CIFilter().vibrance()?
Using swift does iOS 13.4 have class CIVibrance or a string "CIVibrance" or the method CIFilter().vibrance()?
正在寻找 class CIVibrance 或字符串 "CIVibrance" 或 swift 中的 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”)或 select“文件”»“快速打开...”菜单,然后搜索方法或 class 名称:
这通常会让您知道它可能在哪里。在这种情况下:
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: [=11=]) }
}
}
产量:
(左侧为 original image,右侧为充满活力的再现)
正在寻找 class CIVibrance 或字符串 "CIVibrance" 或 swift 中的 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”)或 select“文件”»“快速打开...”菜单,然后搜索方法或 class 名称:
这通常会让您知道它可能在哪里。在这种情况下:
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: [=11=]) }
}
}
产量:
(左侧为 original image,右侧为充满活力的再现)