1

Looking for class CIVibrance or a string "CIVibrance" or the method like CIFilter().vibrance() in swift. Looking at the docs some appear unavailable in swift but others are missing from 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
    }
}

1 Answers1

2

You can press shift+command+o (the letter “oh”) or select “File” » “Open Quickly...” menu, and search for the method or class name:

enter image description here

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:

enter image description here

(with original image on left, vibrant rendition on right)

Rob
  • 415,655
  • 72
  • 787
  • 1,044