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