tom*_*lum 5 cgcolor uicolor ios swift
如果设备支持,是否可以有条件地选择标准 RGB 颜色或 P3 颜色?
对于 iOS 版本,我想过类似以下的事情:
if #available(iOS 12.0, *) {
...
} else {
...
}
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
您可以查询“主屏幕”
let hasP3Display = UIScreen.main.traitCollection.displayGamut == .P3
Run Code Online (Sandbox Code Playgroud)
或特定视图的显示(如果使用外部显示器,则可能会有所不同)
let hasP3Display = view.traitCollection.displayGamut == .P3
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
253 次 |
| 最近记录: |