遮挡原因 : iOS7之后导航栏新增了Translucent属性(透明度)导致View视图向上延伸
方法一
设置导航栏透明度:
swift :self.navigationController?.navigationBar.isTranslucent = false
OC :[self.navigationController.navigationBar setTranslucent:NO];
方法二
设置视图不延伸
swift :self.extendedLayoutIncludesOpaqueBars = false
self.edgesForExtendedLayout = UIRectEdge.init(rawValue: 0)
self.modalPresentationCapturesStatusBarAppearance = false;
OC :self.extendedLayoutIncludesOpaqueBars = NO;
self.edgesForExtendedLayout = UIRectEdgeTop;
self.modalPresentationCapturesStatusBarAppearance = NO
方法三
为导航栏设置背景图
swift:self.navigationController?.navigationBar.setBackgroundImage(UIImage.init(named: "back.png"), for: UIBarMetrics.default)
OC :[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"button_bg_88b048.png"] forBarMetrics:UIBarMetricsDefault]