In AppKit, the size of the view in points is retrievable via the frame
. Since 10.7, each screen additionally has a backingScaleFactor
. The size in pixels that the view will therefore appear at on a given screen can be found by multiplying the size of the frame by the backing scale factor of the screen.
E.g. on a computer with exactly one screen you can do:
CGFloat backingScaleFactor = [[NSScreen mainScreen] backingScaleFactor];
NSSize pixelSize =
NSSizeMake(
view.frame.size.width * backingScaleFactor,
view.frame.size.height * backingScaleFactor);
So I guess one answer is to take the largest scale factor of anything in [NSScreen screens]
.
EDIT: ... but a much better answer would be to use the view's convertSizeToBacking:
— e.g.
pixelSize = [view convertSizeToBacking:view.frame.size];