『IOS』ios8中的UIScreen
来源:互联网 发布:中日友好靠韩国 知乎 编辑:程序博客网 时间:2024/04/20 04:29
1、在ios7中UIScreen.mainScreen().bounds是固定不变的值,在ios8中他的值是随横竖屏改变的!
在ios8中增加了2个属性:
nativeBounds : 屏幕像素,不随横竖平改变的!
nativeScale :1(non retina)/2(retina)/3(retina hd)
3、从UIScreen.mainScreen().applicationFrame输出值看出,ios8默认横屏statusbar是隐藏掉了。你可以根据plist中
View controller-based status bar appearance的值的不同来用
Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?
Yes, it's orientation-dependent in iOS8, not a bug. You could review session 214 from WWDC 2014 for more info: "View Controller Advancements in iOS 8"
Quote from the presentation:
UIScreen is now interface oriented:
- [UIScreen bounds] now interface-oriented
- [UIScreen applicationFrame] now interface-oriented
- Status bar frame notifications are interface-oriented
- Keyboard frame notifications are interface-oriented
+ (CGSize)screenSize { CGSize screenSize = [UIScreen mainScreen].bounds.size; if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) { return CGSizeMake(screenSize.height, screenSize.width); } return screenSize;}
+ (CGRect)screenBoundsFixedToPortraitOrientation { UIScreen *screen = [UIScreen mainScreen]; if ([screen respondsToSelector:@selector(fixedCoordinateSpace)]) { return [screen.coordinateSpace convertRect:screen.bounds toCoordinateSpace:screen.fixedCoordinateSpace]; } return screen.bounds;}
#ifndef NSFoundationVersionNumber_iOS_7_1# define NSFoundationVersionNumber_iOS_7_1 1047.25#endif@implementation UIScreen (Legacy)// iOS 8 way of returning bounds for all SDK's and OS-versions- (CGRect)boundsRotatedWithStatusBar{ static BOOL isNotRotatedBySystem; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ BOOL OSIsBelowIOS8 = [[[UIDevice currentDevice] systemVersion] floatValue] < 8.0; BOOL SDKIsBelowIOS8 = floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1; isNotRotatedBySystem = OSIsBelowIOS8 || SDKIsBelowIOS8; }); BOOL needsToRotate = isNotRotatedBySystem && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); if(needsToRotate) { CGRect screenBounds = [self bounds]; CGRect bounds = screenBounds; bounds.size.width = screenBounds.size.height; bounds.size.height = screenBounds.size.width; return bounds; } else { return [self bounds]; }}@end
#define SCREEN_WIDTH (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height) : [[UIScreen mainScreen] bounds].size.width)#define SCREEN_HEIGHT (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width) : [[UIScreen mainScreen] bounds].size.height)#define IOS_VERSION_LOWER_THAN_8 (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1)
0 0
- 『IOS』ios8中的UIScreen
- ios8中的UIScreen
- ios8中的UIScreen
- ios8中的UIScreen
- iOS8中的[UIScreen mainScreen].bounds 和 [UIScreen mainScreen].applicationFrame
- iOS8中的UIScreen、UIWindow、键盘尺寸、状态栏尺寸的改动
- iOS8中的[UIScreen mainScreen].bounds 和 [UIScreen mainScreen].applicationFrame(下)
- IOS开发中的UIScreen、UIView、UIWindow和UIViewController
- IOS开发中的UIScreen、UIView、UIWindow和UIViewController
- IOS开发中的UIScreen、UIView、UIWindow和UIViewController
- IOS开发中的UIScreen、UIView、UIWindow和UIViewController
- IOS开发中的UIScreen、UIView、UIWindow和UIViewController
- IOS开发中的UIScreen、UIView、UIWindow和UIViewController
- iOS [UIScreen mainScreen].scale
- [iOS] 初探 iOS8 中的 Size Class
- [iOS] 初探 iOS8 中的 Size Class
- [iOS] 初探 iOS8 中的 Size Class
- [iOS] 初探 iOS8 中的 Size Class
- Android中的AppWidget
- MySQL常用命令用法总结
- 网站权限设计实现——套用JQuery EasyUI列表显示数据、分页、查询
- 符合国家快递给他盾更多更快对方沟通的更好的感觉大家分工
- 我为什么使用CSDN
- 『IOS』ios8中的UIScreen
- 泛型练习1(from李兴华)
- postgre表空间管理
- TeamViewer
- Beginning Python From Novice to Professional (4) - 字符串格式示例
- JVM源码分析-Java运行
- 校园助手APP--腾讯地图的集成使用(含街景)
- 一段有关List下集合性能的实验+JDK下源码
- Random 不重复