Swift UNavigationItem button display menu labels

69 views Asked by At

I'm new in Swift and I would like to how to do this.

When I touch rightBarButtonItem button I would like the following to appear:

Behavior when button touched

The Test and Test2 text should display in the same view controller.

If I don't touch rightBarButtonItem the Test and Test2 should not display. (Test and Test2 isHidden will be true.)

Behavior when button not touched

Is this possible or do I need another way?

I have been searching for a long time on the internet. But I have not been able to find anything. Please help or try to give some ideas of how to achieve this.

1

There are 1 answers

0
Mina On BEST ANSWER

This is possible, you can add Test and Test2 in a view or stackView, then change the isHidden property of the view. but as Matthew said, apple prefer to use tab bars.

set the view isHidden property to true in ViewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()
    customView.isHidden = true
}
@IBOutlet weak var customView: UIView!

@IBAction func rightBarButtonClick(_ sender: UIBarButtonItem) {
    customView.isHidden = !customView.isHidden
}

you can also use SWReveal pod.

or you can create it by yourself in swift using this raywenderlich document