ios版本适配,机型适配,横竖屏适配

来源:互联网 发布:淘宝购物流程图模板 编辑:程序博客网 时间:2024/05/20 06:27

1,版本适配: iOS系统的判定,这个可以通过[[[UIDevice currentDevice] systemVersion] floatValue]来获得当前的系统版本。

2,机型适配(屏幕尺寸):

                           #define DEVICE_IS_IPHONE4S ([[UIScreenmainScreen] bounds].size.height == 480)

                           #define DEVICE_IS_IPHONE5 ([[UIScreenmainScreen] bounds].size.height == 568)

                           #define DEVICE_IS_IPHONE6 ([[UIScreenmainScreen] bounds].size.height == 667)

                           #define DEVICE_IS_IPHONE6_Plus ([[UIScreenmainScreen] bounds].size.height == 960)

3,横竖屏适配:(根据使用layoutSubviews方法,检测横竖屏)

              -(void)layoutSubviews{

                 [super layoutSubviews];

                 UIDeviceOrientation  interfaceOrientation = [[UIApplicationsharedApplication] statusBarOrientation];

                 if(interfaceOrientation ==UIDeviceOrientationPortrait || interfaceOrientation ==UIDeviceOrientationPortraitUpsideDown){

            //翻转为竖屏时

               [self setVerticalFrame];

               }else if (interfacePrientation ==UIDeviceOrientationLandscapeLeft || interfaceOrientation ==UIDeviceOrientationLandscapeRight){

           //翻转为横屏时

               [self setHorizontalFrame];

                 }

             }

 

          -(void)setVerticalFrame

           {

              NSLog(@"竖屏");

             [titleLable setFrame:CGRectMake(283,0,239,83)];

             [leftView setFrame:CGRectMake(34,102,384,272)];

           }

 

        -(void)setHorizontalFrame

          {

             NSLog(@"横屏");

             [titleLable setFrame:CGRectMake(183, 0, 239, 83)];

          }


0 0
原创粉丝点击