其他分享
首页 > 其他分享> > iOS获取当前屏幕的尺寸和分辨率

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;

 

标签:UIScreen,scale,screen,iOS,屏幕,CGFloat,分辨率,size
来源: https://www.cnblogs.com/Free-Thinker/p/14984915.html