How can I change the image in the right button of the navigation bar when I select a specific cell?
A good example is in the picture where the rightBarButtonItem image is different based on the selected cell:
How can I change the image in the right button of the navigation bar when I select a specific cell?
A good example is in the picture where the rightBarButtonItem image is different based on the selected cell:
vivekDas
On
You can try below code to creating and set UIBarButtonItem as navigationItem.
let updateButton = UIBarButtonItem(image: YourImage, style: .plain, target: self, action: #selector(buttonAction))
navigationItem.rightBarButtonItem = updateButton
@objc func buttonAction() {
}
So in your didSelectRowAt indexPath delegate method according to condition create and set UIBarButtonItem as required.
Copyright © 2021 Jogjafile Inc.

You can simply add a right bar button item in the navigation bar with this code in the viewDidLoad:
(change the systemItem with your image)
Add an IBOutlet like this:
and connect it to the navigation item in your storyboard.
Then in your didSelectRowAtIndexPath you can handle it with this sample code: