Checking if UIGraphicsBeginImageContextWithOptions is supported

后端 未结 3 978
时光说笑
时光说笑 2021-01-13 02:27

I\'m working on an iOS app. It currently only works on iOS 4 since I use the following method on several occasions: \"UIGraphicsBeginImageContextWithOptions\". This method i

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 03:23

    UIGraphicsBeginImageContextWithOptions is a C function, so you can't use Objective-C methods like -respondsToSelector: to test its existence.

    You could, however, weak link the UIKit framework, and then check if UIGraphicsBeginImageContextWithOptions is NULL:

    if (UIGraphicsBeginImageContextWithOptions != NULL) {
       UIGraphicsBeginImageContextWithOptions(...);
    } else {
       UIGraphicsBeginImageContext(...);
    }
    

提交回复
热议问题