I'm looking to find the value that "About this Mac" shows (2560 x 1600 on my 13" MBP). I have tried CGDisplayBounds and NSScreen.main, both do not return those values but instead return what is used internal for rendering / measuring.
as by Kens suggestion:
let modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), [kCGDisplayShowDuplicateLowResolutionModes: kCFBooleanTrue] as CFDictionary) as! [CGDisplayMode]
for mode in modes {
let flags = String(format:"%02X", mode.ioFlags)
print("(mode.pixelWidth)x(mode.pixelHeight) (mode.width)x(mode.height) 0x(flags)")
}
Output is:
2560x1600 2560x1600 0x2000003 <- This would be the correct one
...
2880x1800 2880x1800 0x03 <- This one is the biggest 1x mode
...
So using the biggest 1x would get the wrong result. I added the ioFlags to the output. I belive this might the missing link;-)
Thank you Ken!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…