Код: Выделить всё
class CustomNavigationViewController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// change height
let customNavigationBar = CustomNavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 68))
view.addSubview(customNavigationBar)
// change button size
let customButton = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 44, height: 44))
customButton.setImage(UIImage.init(named:"iOS2"), for: .normal)
let customNavigationItem = UINavigationItem()
customNavigationItem = UIBarButtonItem.init(customView: customButton)
customNavigationBar.items = [customNavigationItem]
}
}
class SLNavigationBar: UINavigationBar {
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
private func commonInit() {
backgroundColor = .white
}
}

Но я хочу получить этот результат (обратите внимание на положение зеленого квадрата) с ограничением верхней части кнопки = 12:

Как изменить верхнее ограничение UIBarButtonItem?
Подробнее здесь: https://stackoverflow.com/questions/786 ... buttonitem