I need to write a number on top of one of my navigation bar items ( on the shopping cart picture)
I tried to connect it with an outlet and using this code but it didn't work.
self.BtnSabadNav.title = "3"
I also tried this code but it didn't work too.
self.navigationItem.leftBarButtonItem?.title = "fdf"
how should I do this?
You would need to have a custom UIView
which would contain a UIImage
and UILabel
. Then you need to set the custom view to the UIBarBarButtonItem
.
let barButtonItem = UIBarButtonItem(customView: yourCustomView)
self.navigationItem.leftBarButtonItem = barButtonItem