2018-07-03

UIDeviceOrientation、UIInterfaceOrientation、UIInterfaceOrientationMask区别

1、UIDeviceOrientation:设备的物理方向

typedef enum UIDeviceOrientation : NSInteger {

    UIDeviceOrientationUnknown, // 无法确定设备的方向

    UIDeviceOrientationPortrait, // 设备处于竖屏模式,设备直立,底部有home键

    UIDeviceOrientationPortraitUpsideDown, // 设备处于竖屏模式,但上下颠倒,设备保持直立,home按钮位于顶部。

    UIDeviceOrientationLandscapeLeft, // 设备处于横屏模式,设备直立,右侧为home键

    UIDeviceOrientationLandscapeRight, // 设备处于横屏模式,设备直立,左侧为home键

    UIDeviceOrientationFaceUp, // 设备与地面平行,屏幕朝上                                                

    UIDeviceOrientationFaceDown // 设备与地面平行,屏幕朝下。

} UIDeviceOrientation;


2、UIInterfaceOrientation:应用程序用户界面的方向

typedef enum UIInterfaceOrientation : NSInteger {

    UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,

    UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,

    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,

    UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,

    UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft

} UIInterfaceOrientation;

注意:UIDeviceOrientationLandscapeRight分配给UIInterfaceOrientationLandscapeLeft, UIDeviceOrientationLandscapeLeft分配给UIInterfaceOrientationLandscapeRight;原因是旋转设备需要将内容旋转到相反的方向。

3、UIInterfaceOrientationMask:这些常量是指定视图控制器支持的接口方向的掩码位

typedef enum UIInterfaceOrientationMask : NSUInteger {

    UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait), // 视图控制器支持纵向界面方向。

    UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft), // 视图控制器支持景观左界面朝向

    UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight), // 视图控制器支持景观右界面朝向

    UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown), // 视图控制器支持一个倒置的纵向界面方向。

    UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), // 视图控制器同时支持景观向左和景观向右的界面朝向

    UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown), // 视图控制器支持所有的接口方向。

    UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight) // 视图控制器支持所有的,除了颠倒的人像界面朝向。

} UIInterfaceOrientationMask;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容