NavigationBar一些必须要记住的细节问题

left、right barItems与系统的barItem与屏幕边距差异

解决方法:
通过定义额外的barItem

let spaceBarItem = UIBarButtonItem.init(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
spaceBarItem.width = -12
self.navigationItem.leftBarButtonItems = [spaceBarItem, UIBarButtonItem.init(customView: textField)]

自定义返回backBarItem时,系统左滑返回失效

解决方法:

let backBarButtomItem = UIBarButtonItem.init(image: UIImage.init(named: "backStretchBackgroundNormal"), style: .Plain, target: self, action:#selector(XcfBuyBuyBuyVIewController.navgationPop))      
self.navigationItem.leftBarButtonItem = backBarButtomItem    
self.navigationController!.interactivePopGestureRecognizer!.delegate = self

隐藏返回按钮,左滑时导航栏出现三个点

解决方法:
定义一个空的leftBar

let leftBarView = UIView.init(frame: CGRectZero)
let leftBarItem = UIBarButtonItem.init(customView: leftBarView)
self.navigationItem.leftBarButtonItem = leftBarItem

你可能感兴趣的:(NavigationBar一些必须要记住的细节问题)