UIScreen学习记录
转载自 http://blog.csdn.net/fww330666557/article/details/11918539
A UIScreen
object contains the bounding rectangle of the device’s entire screen. When setting up your application’s user interface, you should use the properties of this object to get the recommended frame rectangles for your application’s window.
UIScreen对象包含了整个屏幕的边界矩形。当构造应用的用户界面接口时,你应该使用该对象的属性来获得推荐的矩形大小,用以构造你的程序窗口。
以下列出的属性和操作是我用过的。
+ mainScreen Returns the screen object representing the device’s screen.
bounds property Contains the bounding rectangle of the screen, measured in points. (read-only)
applicationFrame property The frame rectangle for the app window. (read-only)
scale property The natural scale factor associated with the screen. (read-only)
CGRect bound = [[UIScreen mainScreen] bounds]; // 返回的是带有状态栏的Rect
CGRect frame = [[UIScreen mainScreen] applicationFrame]; // 返回的是不带有状态栏的Rect
float scale = [[UIScreen mainScreen] scale]; // 得到设备的自然分辨率
备注:状态栏高度为20
根据不同设备获取到的参数数据:
1. iphone 6s plus
//设备类型
NSString* deviceType = @"iphone 6s plus";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出结果:
[iphone 6s plus] mainScreen.bounds:{{0, 0}, {414, 736}}
[iphone 6s plus] mainScreen.applicationFrame:{{0, 20}, {414, 716}}
[iphone 6s plus] mainScreen.scale:3.000000
[iphone 6s plus] mainScreen.brightness:0.500000
2. iphone 6s //设备类型
NSString* deviceType = @"iphone 6s";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出结果:
[iphone 6s] mainScreen.bounds:{{0, 0}, {375, 667}}
[iphone 6s] mainScreen.applicationFrame:{{0, 20}, {375, 647}}
[iphone 6s] mainScreen.scale:2.000000
[iphone 6s] mainScreen.brightness:0.500000
3. iphone 6 plus
//设备类型
NSString* deviceType = @"iphone 6 plus";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出结果:
[iphone 6 plus] mainScreen.bounds:{{0, 0}, {414, 736}}
[iphone 6 plus] mainScreen.applicationFrame:{{0, 20}, {414, 716}}
[iphone 6 plus] mainScreen.scale:3.000000
[iphone 6 plus] mainScreen.brightness:0.500000
4. iphone 6
//设备类型
NSString* deviceType = @"iphone 6";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出:
[iphone 6] mainScreen.bounds:{{0, 0}, {375, 667}}
[iphone 6] mainScreen.applicationFrame:{{0, 20}, {375, 647}}
[iphone 6] mainScreen.scale:2.000000
[iphone 6] mainScreen.brightness:0.500000
5. iphone 5s
//设备类型
NSString* deviceType = @"iphone 5s";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出:
[iphone 5s] mainScreen.bounds:{{0, 0}, {320, 568}}
[iphone 5s] mainScreen.applicationFrame:{{0, 20}, {320, 548}}
[iphone 5s] mainScreen.scale:2.000000
[iphone 5s] mainScreen.brightness:0.500000
6. iphone 5
//设备类型
NSString* deviceType = @"iphone 5";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出:
[iphone 5] mainScreen.bounds:{{0, 0}, {320, 568}}
[iphone 5] mainScreen.applicationFrame:{{0, 20}, {320, 548}}
[iphone 5] mainScreen.scale:2.000000
[iphone 5] mainScreen.brightness:0.500000
7. iphone 4s
//设备类型
NSString* deviceType = @"iphone 4s";
//显示分辨率
UIScreen* mainScreen = [UIScreen mainScreen];
//bounds:只读属性,返回整个屏幕的rect (包含顶部的状态栏)
NSLog(@"[%@] mainScreen.bounds:%@",deviceType,NSStringFromCGRect(mainScreen.bounds));
//applicationFrame:只读属性,返回状态栏之下的屏幕的rect (不包含顶部的状态栏)
NSLog(@"[%@] mainScreen.applicationFrame:%@",deviceType,NSStringFromCGRect(mainScreen.applicationFrame));
//设备的分辨率:只读属性
NSLog(@"[%@] mainScreen.scale:%f",deviceType,mainScreen.scale);
//屏幕亮度:取值范围为0-1.0
NSLog(@"[%@] mainScreen.brightness:%f",deviceType,mainScreen.brightness);
输出:
[iphone 4s] mainScreen.bounds:{{0, 0}, {320, 480}}
[iphone 4s] mainScreen.applicationFrame:{{0, 20}, {320, 460}}
[iphone 4s] mainScreen.scale:2.000000
[iphone 4s] mainScreen.brightness:0.500000
- 大小: 158.8 KB
分享到:
相关推荐
NULL 博文链接:https://justsee.iteye.com/blog/2154757
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) //-------------------获取设备大小----判断5--------------------- #define...
YGGravityImageView *imageView = [[YGGravityImageView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; imageView.image = ...
一款不错的屏幕截图功能源码,主要我们点击按钮进行截屏操作了,同时也可以将截屏图像保存到相册中等功能,大家可以下载学习看看吧。 //获取当前屏幕内容 - (UIImage *)getNormalImage:(UIView *)view{ float ...
public let BGMainScrrenBounds = UIScreen.mainScreen().bounds /// 屏幕大小 public let BGMainScrrenSize = UIScreen.mainScreen().bounds.size /// 屏幕宽度 public let BGMainScreenWidth = UIScreen....
focusView3.frame = CGRectMake(20, 20, [UIScreen mainScreen].bounds.size.width-40, [UIScreen mainScreen].bounds.size.height-40); [self.view addSubview:focusView3]; focusView3.delegate =self; ...
runtime字体大小适配 (void)load{ //获取替换后的类方法 Method newMethod = class_... newFont = [UIFont adjustFont:fontSize * [UIScreen mainScreen].bounds.size.width/YourUIScreen]; return newFont; }
iOS 工具类,NSString,UIImage等。###目前包括以下几类 * UIImage * UIScreen * UIView * NSString
#define SCREEN_W [UIScreen mainScreen].bounds.size.width #define SCREEN_H [UIScreen mainScreen].bounds.size.height #define TOP 200 //顶部预留 #import ViewController.h @interface ViewController ()<...
这两天学习了iOS屏幕亮度和闪光灯控制,所以,今天添加一点小笔记。 所用涉及框架:AVFoundation框架和ImageIO 读取屏幕亮度:[UIScreen mainScreen].brightness; 设置屏幕亮度:[[UIScreen mainScreen] ...
前言 宏定义在C系开发中可以说占有举足轻重的作用,为了简化开发流程,提升...#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) //
pch 可以用来存储共享信息,比如设备屏幕的宽度,...#define SCREEN_FRAME ([UIScreen mainScreen].applicationFrame) #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) #define SCREEN_HEIGHT ([UISc
迅捷补间 Swift动画引擎,制作功能更强大且更具创意的应用程序。 该项目已使用纯Swift重写 先决条件 斯威夫特5.0 特征 ... width :UIScreen. main . bounds . width - 40 , height :UIScreen. main .
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height #define ScreenWidth [[UIScreen mainScreen] bounds].size.width 控制器.m文件 这里的imageView是用来装手势画图之后的image,看后面就清楚了 ...
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height #define JHRGB(r,g,b) [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b...
YBJScrollView A simple multicast map 第一个轮播图 - (void)viewDidLoad { ... YBJ_ScrollView * Scroll = [[YBJ_ScrollView alloc] initWithFrame:CGRectMake(0, 20, UIScreen_Width, UIScreen_Width
TagList自定义标签显示控件,简单灵活易用,功能点如下:1:可动态 添加/删除 一个或多个 标签2:根据当前tag内容多少... bounds].size.width#define kMainScreenHeight [[UIScreen mainScreen] bounds].size.height@i
FFBannerView *bannerVew = [FFBannerView bannerViewWithFrame:CGRectMake(0, 250, [UIScreen mainScreen].bounds.size.width, 200) netWorkImageArray:array placeHolderImage:nil]; bannerVew.timeInterval = ...
window = UIWindow(frame: UIScreen.main.bounds) if !UserDefaults.standard.bool(forKey: "alreadyUsedApp"){ // 未使用过App,首次使用 let images:[UIImage] = [UIImage(named:"1")!,UIImage(named:...