[Solved] How to put the burger icon in a UIBarButtonItem?


You’ll want to use the UIBarButtonItem constructor init(image: UIImage?, style: UIBarButtonItemStyle, target: Any?, action: Selector?)

an example usage would be:

self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "burger_icon"), style: .plain, target: self, action: #selector(self.someMethod))

In this example “burger_icon” is the name of the image asset in your project and self.someMethod is the method that is called when this button is tapped.

For more information on the UIBarButtonItem class you can look at the Apple documentation for the class. https://developer.apple.com/reference/uikit/uibarbuttonitem

solved How to put the burger icon in a UIBarButtonItem?