【问题标题】:How do I determine if current device does have a P3 capable display?如何确定当前设备是否具有支持 P3 的显示器?
【发布时间】:2019-11-10 06:10:26
【问题描述】:

如果设备支持,有没有办法有条件地选择标准 RGB 颜色或 P3 颜色?

我为 iOS 版本考虑过类似以下内容:

if #available(iOS 12.0, *) {
    ...
} else {
    ...
}

【问题讨论】:

    标签: ios swift uicolor cgcolor


    【解决方案1】:

    UITraitCollection 有一个displayGamut 属性,即enum UIDisplayGamut

    @available(iOS 10.0, *)
    public enum UIDisplayGamut : Int {
        case unspecified // UIKit will not set this anymore, instead a sensible default is chosen based on the device capabilities and settings always
        case SRGB
        case P3
    }
    

    可以查询“主屏”

    let hasP3Display = UIScreen.main.traitCollection.displayGamut == .P3 
    

    或特定视图的显示(如果使用外部监视器,可能会有所不同)

    let hasP3Display = view.traitCollection.displayGamut == .P3
    

    【讨论】:

    • 只有当您 100% 确定用户不会在您的应用中使用任何外部屏幕时,才应使用前者。或者,如果您不关心它在外接显示器上的外观。
    猜你喜欢
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多