AtulParmar
AtulParmar

Reputation: 4570

Hide or remove specific item from navigation bar button items, Swift 4

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?

Upvotes: 2

Views: 1932

Answers (1)

rodskagg
rodskagg

Reputation: 3927

Try this:

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

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

Upvotes: 3

Related Questions