天天看點

iOS7和iOS6适配,和保留之前的坐标編碼習慣,不用刻意加減

//目的:用于iOS7和iOS6适配,和保留之前的坐标編碼習慣,不用刻意加減

void IOS7ToIOS6ofFrame(UIViewController *vc);

void IOS7ToIOS6ofBounds(UIViewController *vc);

void IOS7ToIOS6ofFrame(UIViewController *vc){   

if (IsIOS7) {       

CGRect rect = vc.view.frame;       

vc.view.frame = CGRectMake((rect.origin.x), (rect.origin.y+(IsIOS7?vc.topLayoutGuide.length:0)), (CGRectGetWidth(rect)), (CGRectGetHeight(rect)-(IsIOS7?vc.topLayoutGuide.length:0)));    }}

void IOS7ToIOS6ofBounds(UIViewController *vc)

{   

if (IsIOS7) {          

CGRect rect = vc.view.bounds;      

if (rect.origin.y != -1*vc.topLayoutGuide.length) {        

   vc.view.bounds = CGRectMake((rect.origin.x), (rect.origin.y+(IsIOS7?vc.topLayoutGuide.length*(-1):0)), (CGRectGetWidth(rect)), (CGRectGetHeight(rect)));        }  

}}

#define IOS7 if([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=7)

{   self.extendedLayoutIncludesOpaqueBars = NO;\

     self.modalPresentationCapturesStatusBarAppearance =NO;

     \self.edgesForExtendedLayout = UIRectEdgeNone;

 }

#define IsIOS7 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=7)

#define CGRECT_NO_NAV(x,y,w,h) CGRectMake((x), (y+(IsIOS7?20:0)), (w), (h))

#define CGRECT_HAVE_NAV(x,y,w,h) CGRectMake((x), (y+(IsIOS7?64:0)), (w), (h))