Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScreen.mainScreen.scale on NSScreen

I have a problem with CATextLayer cleaning. and with iOS the solution is:

textLayer.contentsScale = UIScreen.mainScreen.scale

But I can't found "scale" property on cocoa NSScreen

Note: Answer with Object-C or Swift are OK.

like image 517
Huynh Inc Avatar asked Jul 03 '15 02:07

Huynh Inc


3 Answers

[[NSScreen mainScreen] backingScaleFactor] will give you the scaling factor for main display

like image 131
sac Avatar answered Nov 15 '22 11:11

sac


I'm not sure it's the same as on iOS but NSScreen has backingScaleFactor, which might do the trick.

like image 38
Frank R. Avatar answered Nov 15 '22 10:11

Frank R.


swift 4.2:

(NSScreen.main?.backingScaleFactor)!
like image 2
roberto Avatar answered Nov 15 '22 12:11

roberto