Since iOS 11 and Xcode 9 barbuttonitems and titles aren't visible anymore. It doesn't matter whether I'm trying to add a custom view like this:
let backButton = UIButton.init(frame: CGRect(x: 0, y: 0, width: 180, height: 32))
backButton.setImage(UIImage(named: "back_icon")?.withRenderingMode(.alwaysTemplate), for: .normal)
backButton.tintColor = UIColor.white
backButton.addTarget(self, action: #selector(backAction), for: .touchUpInside)
backButton.backgroundColor = UIColor.clear
backButton.titleLabel?.font = UIFont(name: SWMainHelper.sharedInstance.mediumFont, size: 18)
backButton.setTitleColor(UIColor.white, for: .normal)
backButton.setTitle("Go back", for: .normal)
backButton.sizeToFit()
backButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0)
backButton.frame.size.width += 16
let negativeButtonSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
negativeButtonSpace.width = -16
self.navigationItem.setLeftBarButtonItems([negativeButtonSpace, UIBarButtonItem(customView: backButton)], animated: true)
or just standard UIBarButtonItems like that:
let add = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addTapped))
add.tintColor = UIColor.white
let play = UIBarButtonItem(title: "Play", style: .plain, target: self, action: #selector(playTapped))
play.tintColor = UIColor.white
navigationItem.rightBarButtonItems = [add, play]
With Xcode 8 everything worked fine.