I am using init(title:image:primaryAction:menu:)
of a UIBarButtonItem Apple Documentation on a Toolbar with the hope of showing a button with both image and title. Does anyone know why the title does not show?
I am not looking for a custom implementation that can add a UIBarButtonItem with title and image. I have seen plenty on Stackoverflow. I just want to use this initializer if it works.
I have a UITableViewController subclass and I have added this code to the viewDidLoad
navigationController?.isToolbarHidden = false
let barButtonItem = UIBarButtonItem(title: "New Item", image: UIImage(systemName: "plus.circle.fill"), primaryAction: nil, menu: nil)
toolbarItems = [barButtonItem]
My guess is that since public convenience init(title: String? = nil, image: UIImage? = nil, primaryAction: UIAction? = nil, menu: UIMenu? = nil)
is a convenience
init, and the fact that there is no init that initialize with both title and image, then using both at the same time is not supported. It's merely a convenience on using primaryAction and menu then having title and image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With