iOS7 之后,我们直接在导航栏添加barbuttonItem时候,会有一定偏移量,
比如:
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btnLeft)
这样布局图片出屏幕,左右可多加一个空白按钮
解决方法:
leftBarButtonItems:
let leftItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
leftItem.width = -20
self.navigationItem.leftBarButtonItems = [leftItem,UIBarButtonItem(customView: btnLeft)]
rightBarButtonItems:
let rightItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
rightItem.width = -20
self.navigationItem.rightBarButtonItems = [rightItem,UIBarButtonItem(customView: btnRight)]
网友评论