RuLoViC
RuLoViC

Reputation: 855

How to get system scale factor on OSX

I am working on an application and I need to get the scale factor used by the system.

So far, I have tried:

[self.window backingScaleFactor];from my view since I have read that [[NSScreen mainScreen] backingScaleFactor]; must be avoided.

However I am getting zero always.

Am I missing something? What does that zero mean?

Thanks in advance

Upvotes: 2

Views: 730

Answers (1)

bobobobo
bobobobo

Reputation: 67286

self.window.backingScaleFactor seems right. Docs have:

The value of this property is 2.0 for high-resolution scaled display modes, and 1.0 for all other cases.

Multiply widths/heights by the backingScaleFactor to scale up to the size the O/S is scaling

Upvotes: 0

Related Questions