如果设备支持,是否可以有条件地选择标准RGB颜色或P3颜色?
我针对iOS版本考虑了以下内容:
if #available(iOS 12.0, *) {
...
} else {
...
}
答案 0 :(得分:4)
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