Unable to find where I made a mistake while creating toolbars.
1 - was created through code, see below
let toolBar = UIToolbar() var items = [UIBarButtonItem]() toolBar.barTintColor = theme.barTintColor let share = UIBarButtonItem(barButtonSystemItem: .action, target: nil, action: nil) items.append(share) items.append(UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)) let trash = UIBarButtonItem(barButtonSystemItem: .trash, target: nil, action: nil) self.view.addSubview(toolBar) toolBar.translatesAutoresizingMaskIntoConstraints = false if #available(iOS 11.0, *) { let guide = self.view.safeAreaLayoutGuide toolBar.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true toolBar.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true toolBar.bottomAnchor.constraint(equalTo: guide.bottomAnchor).isActive = true //toolBar.heightAnchor.constraint(equalToConstant: 44).isActive = true }
2 - was added through the designer
it looks like they have different heights and, as a result, different indents over UIBarButtonItems

EDIT 0 : configured in toolbar 2 storyboard by default

EDIT 1 : The visual debugger shows that _UIToolbarContentView from toolbar 2 higher than _UIToolbarContentView toolbar 1 by 5px .
<_UIToolbarContentView: 0x153e13190; frame = (0 0; 375 49); autoresize = W+H; layer = <CALayer: 0x1d0236d80>> Printing description of $28: <_UIToolbarContentView: 0x15b9f08d0; frame = (0 0; 375 44); autoresize = W+H; layer = <CALayer: 0x1d522af00>>
EDIT 2 : This is a strange behavior on the iPhone X, on the iPhone 6 everything is fine.

toolBar.heightAnchor.constraint(equalToConstant: 49) : If iPhone X, add this hack toolBar.heightAnchor.constraint(equalToConstant: 49)
source share