iOS: 增加 UIBarButtonItem 的间距

iOS: Increase spacing to UIBarButtonItem

我定制了 UINavigationBar 如下所示:[

现在我想增加左右栏按钮之间的间距。我尝试以这种方式使用 UIEdgeInsets 这样做:

self.navigationItem.leftBarButtonItem?.imageInsets = UIEdgeInsetsMake(0, 20, 0, 0)

然后它开始尖叫:

您可以在按钮前添加额外的间距项:

    let button = UIBarButtonItem(title: "<", style: .plain, target: self, action: "someSelector")
    let spacing = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
    spacing.width = 20;
    navigationItem.leftBarButtonItems = [spacing, button]