title: Change views using Segmented Control
body: <p>I need to change views using a Segmented Control. In the following example I have put two view containers in the same location:</p>
  
  <p><a href="https://i.stack.imgur.com/B0fK0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B0fK0.png" alt="enter image description here"></a></p>
  
  <p>The second container is hidden and I will show it through code every time I use the segmented control. (Although it does not show it either.)</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var container1: UIView!
      @IBOutlet weak var container2: UIView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      @IBAction func showComponent(_ sender: Any) {
          if (sender as AnyObject).selectedSegmentIndex == 0 {
              UIView.animate(withDuration: 0.5, animations: {
                  self.container1.alpha = 1
                  self.container2.alpha = 0
              })
          } else {
              UIView.animate(withDuration: 0.5, animations: {
                  self.container1.alpha = 0
                  self.container2.alpha = 1
              })
          }
      }
  
  }
  </code></pre>
  
  <p>Do you know of any other way to do it?</p>
  
  <p>Is there any way to customize the SegmentedControl as if it were a TAB?</p>