Reputation: 399
I'm trying to create a design where a section of the ViewController has three buttons that show different content depending on what button is selected. Basically UITabBarController but within a viewcontroller
Basically the deer, fish and the bird icons will be buttons, showing different content in an imageView below. Is there a built in function in Xcode that you recommend for this? Or should I create three buttons, showing/hiding the relevant UIViews? What is the most efficient?
Upvotes: 0
Views: 41
Reputation: 1000
Your image isn't showing up but could a Segmented Control be what you are after?
Hook its Value Changed up to an action in your View Controller and respond to which item is selected by showing/hiding different views for example:
@IBAction func controlChanged(_ sender: Any) {
guard let segmentedControl = sender as? UISegmentedControl else { return }
let activeViewIndex = segmentedControl.selectedSegmentIndex
// Show the view based on activeViewIndex here
}
Upvotes: 1