简体   繁体   English

使用 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()?

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.

相关问题 当 ObservedObject 在其他 class [Swift 5 iOS 13.4] 中发生变化时如何在 ContentView 中运行方法 - How to run a method in ContentView when an ObservedObject changes in other class [Swift 5 iOS 13.4] CIFilter通过使用imageview已失真(iOS) - CIFilter have by using the imageview is distorted (iOS) 将CIFilter与AVFoundation一起使用(iOS) - Using CIFilter with AVFoundation (iOS) Swift Combine 属性继承在 Xcode 11.4 beta 2 / iOS 13.4 上抛出“致命错误:调用已删除方法” - Swift Combine properties inheritance throws 'Fatal error: Call of deleted method' on Xcode 11.4 beta 2 / iOS 13.4 如何在 Swift 5 和 iOS 13 中使用 CIFilter sunbeamsGenerator? - How to use CIFilter sunbeamsGenerator in Swift 5 and iOS 13? CIFilter使用swift-ROI应用于选定区域 - CIFilter applying to selected area using swift - ROI 自 iOS 13.4 起不再显示购买对话框 - The purchase dialog does not show up since iOS 13.4 iOS Image周围的白色像素使用CIFilter - White pixels around iOS Image using CIFilter 为什么在iOS 13.4之后不执行UIApplication的next方法? - Why is the next method of UIApplication not executed after iOS 13.4? iOS-无法使用CIFilter处理图像 - iOS - Cannot process image using CIFilter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM