Why my Navigation and Normal Buttons text and images are not visible but actionable, when i build app on iphone and as well as when i check app after building an app on simulator?
This is how i am adding button to navigation bar:
@objc func moreNavigationButton() -> UIBarButtonItem {
let barButton:UIButton = UIButton.init(type: .custom)
barButton.addTarget(self, action:#selector(moreNavigationButtonClicked), for: .touchUpInside)
barButton.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
barButton.setImage(UIImage(named: "ic_more"), for: .normal)
barButton.imageView?.contentMode = .scaleAspectFit
let barButtonItem:UIBarButtonItem = UIBarButtonItem.init(customView: barButton)
barButtonItem.width = 30
return barButtonItem
}
In viewWillAppear() function i am calling the above method like following:
self.navigationItem.rightBarButtonItems = [self.moreNavigationButton()]
3
Answers
The below extension was causing this problem. Now i commented it and it is solved.
All right now we have different setting up for button in my side I usually do like that
then after I set 2 barButtonItem
Here I had them to navigation items
navigationItem.rightBarButtonItems = [add, play]
I suppose you need to set Bar button item instead of button.
Thanks to Paul Hudson content It’s always helpful
Let me know if it’s helpful
Good morning every one So this morning I create a new project with the system of create your own navigationBar and your own barButton. Feel free to download fork do some pull request or whatever.
https://github.com/Gioovannii/Navigation-bar/tree/main