I have a bit of code bellow which creates an bar button item to then add to the navigation bar on the right side like many apps do.
The problem I am having is that the button/image do not show up at all.
How can I fix this?
FYI: This code runs as a setup() func after all other code runs in the view did load.
let image = UIImage(systemName: "paperplane")?.withTintColor(.black, renderingMode: .alwaysOriginal)
let button = UIBarButtonItem(image: image,
style: .plain,
target: self,
action: #selector(showDMController))
self.navigationItem.rightBarButtonItem = button
Try this code tested and working for me.
I have added
topItem
to addrightBarButton
. If this does not solve your problem let me know.