2

Hide OR remove specific button item from navigation bar UIBarButtonItem which is given from storyboard.

For example right side navigation bar item I have added 3 UIBarButtonItem like "Done", "Cancel", "next" from storyboard and now I want to remove or Hide "Cancel" button from the navigation bar programmatically as per the user login, So what can I do for this issue?

AtulParmar
  • 4,358
  • 1
  • 24
  • 45
  • Possible duplicate of [Make a UIBarButtonItem disappear using swift IOS](https://stackoverflow.com/questions/25492491/make-a-uibarbuttonitem-disappear-using-swift-ios) – Sateesh Yemireddi Feb 04 '19 at 11:52

1 Answers1

2

Try this:

self.navigationItem.rightBarButtonItems?.remove(at: [indexOfButton])

[indexOfButton] should be the index of the button in the rightBarButtonItems array.

rodskagg
  • 3,827
  • 4
  • 27
  • 46