0

I was wondering how I would link a segment control index with a image view controller. I have designed a slideshow within a page. I have a separate image view controller and segment index. Within the segment index there are four option how would I link a segment index == 0 with one image and segment index == 1 with another image.

@IBAction func changeImage(sender: UISegmentedControl) {

    if sender.selectedSegmentIndex == 0 {
        (What would I type here in order to link with the image view)
    }

}
J.Graham
  • 1
  • 2

1 Answers1

0

Just add a UIImageView IBOutlet and change the image source.

@IBOutlet weak war imageView: UIImageView!

@IBAction func changeImage(sender: UISegmentedControl) {

    if sender.selectedSegmentIndex == 0 {
       imageView.image = UIImage(named: "image1")
    } sender.selectedSegmentIndex == 1 {
       imageView.image = UIImage(named: "image2")
    }
}
John
  • 411
  • 2
  • 8
  • 22