4

I made a custom UINavigationBar looks like this:[1]

Now I want to increase spacing between left and left bar button. I tried to do that this way using UIEdgeInsets this way:

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

Then it gets shrieked 2]:

4

1 回答 1

5

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

    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]
于 2015-08-30T00:14:53.500 回答