Artiom
Artiom

Reputation: 623

UIBarButtonItem hide element and space that it takes

How could i hide UIBarButtonItem and space that it takes?

For hiding i use this code:

searchButton.isEnabled = false
searchButton.tintColor = UIColor.clear

But it still uses the space and if i have a third element it looks like a gap between them. Changing width does not solve my problem.

searchButton.width = 0.0

enter image description hereenter image description here

Upvotes: 1

Views: 106

Answers (2)

Artiom
Artiom

Reputation: 623

The best solution that i found was searchButton.customView = UIView()

Upvotes: 0

cora
cora

Reputation: 2102

navigationItem.rightBarButtonItems Is an optional array of buttons on the right in the navigation bar. You go through it and remove a button from it.

Upvotes: 1

Related Questions