ios版本適配,機型適配,橫豎屏適配

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)];

          }


發佈了23 篇原創文章 · 獲贊 2 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章