【发布时间】:2019-04-08 09:45:16
【问题描述】:
我正在尝试获取以下屏幕分辨率的纵横比是我从中获取宽度高度和刷新率的代码
-(void)getSupportedDisplays{
NSArray* theref = (__bridge NSArray *)(CGDisplayCopyAllDisplayModes ( CGMainDisplayID(), nil ));
NSMutableArray * rezes = [[NSMutableArray alloc]init];
for (id aMode in theref) {
CGDisplayModeRef thisMode = (__bridge CGDisplayModeRef)(aMode);
size_t theWidth = CGDisplayModeGetWidth( thisMode );
size_t theHeight = CGDisplayModeGetHeight( thisMode );
double refresh = CGDisplayModeGetRefreshRate(thisMode);
NSString *theRez = [NSString stringWithFormat:@"%zux%zu %d Hz",theWidth,theHeight,(int)refresh];
if (![rezes containsObject:theRez]) {
[rezes addObject:theRez];
}
}
NSLog(@" display deatails = %@", rezes);
}
我想要每个分辨率的宽高比是这样的
有什么建议吗?
提前致谢!!!
【问题讨论】:
标签: objective-c macos aspect-ratio