objective c - How can I get all supported screen resolutions on mac OSX Swift -
i want code that
1)grabs current screen resolution, (solved).
for example : current screen display code :
system_profiler spdisplaysdatatype |grep resolution
2)grabs supported resolution shown in picture below (unsolved).
or objective c code useful
swift code
var displayconfig: cgdisplayconfigref = nil let maindisplayid = cgmaindisplayid() var displaymode = cgdisplaycopydisplaymode(maindisplayid).takeretainedvalue() var width = cgdisplaymodegetwidth(displaymode) var height = cgdisplaymodegetheight(displaymode) print("current size: \(width)x\(height)\n") print("available sizes:\n") var modes = cgdisplaycopyalldisplaymodes(maindisplayid, nil).takeretainedvalue() let modescount = cfarraygetcount(modes) - 1 in 0...modescount { var mode: cgdisplaymoderef = unsafebitcast(cfarraygetvalueatindex(modes, i), cgdisplaymoderef.self) var width = cgdisplaymodegetwidth(mode) var height = cgdisplaymodegetheight(mode) print("\t\(width)x\(height)\n")
Comments
Post a Comment