iOS获取当前屏幕的尺寸和分辨率

//1、得到当前屏幕的尺寸:
CGRect rect_screen = [[UIScreen mainScreen] bounds];
CGSize size_screen = rect_screen.size;

//2、获得scale:iPhone5和iPhone6是2,iPhone6Plus是3
CGFloat scale_screen = [UIScreen mainScreen].scale;
NSLog(@"scale_screen:%.f", scale_screen);

//3.获取当前屏幕的分辨率
CGFloat widthResolution = size_screen.width * scale_screen;
CGFloat heightResolution = size_screen.height * scale_screen;

 

posted @ 2021-07-08 10:24  brave-sailor  阅读(42)  评论(0编辑  收藏  举报