public

NSScreen+HighestDensity.h

  • Download Gist
NSString+HighestDensity.m
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#import "NSScreen+HighestDensity.h"
 
@implementation NSScreen (HighestDensity)
 
+ (CGFloat)highestDensity {
// Support for OSX 10.6
if (![[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) return 1.0f;
NSArray *screens = [NSScreen screens];
CGFloat highestDensity = 1.0f;
for (NSScreen *screen in screens) {
if ([screen backingScaleFactor] > highestDensity) {
highestDensity = [screen backingScaleFactor];
}
}
return highestDensity;
}
 
@end
NSStringHighestDensity.m
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#import "NSScreen+HighestDensity.h"
 
@implementation NSScreen (HighestDensity)
 
+ (CGFloat)highestDensity {
// Support for OSX 10.6
if (![[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) return 1.0f;
NSArray *screens = [NSScreen screens];
CGFloat highestDensity = 1.0f;
for (NSScreen *screen in screens) {
if ([screen backingScaleFactor] > highestDensity) {
highestDensity = [screen backingScaleFactor];
}
}
return highestDensity;
}
 
@end
gistfile1.m
Objective-C
1 2 3 4 5 6 7
#import <Cocoa/Cocoa.h>
 
@interface NSScreen (HighestDensity)
 
+ (CGFloat)highestDensity;
 
@end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.