我制作了一个自定义UINavigationBar
,如下所示:[
现在我想增加左右按钮之间的间距。我尝试以这种方式使用UIEdgeInsets
这样做:
self.navigationItem.leftBarButtonItem?.imageInsets = UIEdgeInsetsMake(0, 20, 0, 0)
然后它被尖叫:
答案 0 :(得分:2)
您可以在按钮之前添加额外的间距项:
let button = UIBarButtonItem(title: "<", style: .Plain, target: self, action: "someSelector")
let spacing = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
spacing.width = 20;
navigationItem.leftBarButtonItems = [spacing, button]