一起去旅行吧! # Segmented control

Lynn
彼得潘的 Swift iOS / Flutter App 開發教室
3 min readAug 18, 2018
import UIKitclass ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.}}import UIKitclass SecondViewController: UIViewController {@IBOutlet weak var goUIbutton: UIButton!@IBOutlet weak var displayImageView: UIImageView!override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.}@IBAction func pressedSegmented(_ sender: UISegmentedControl) {if ( sender.selectedSegmentIndex == 0 ){displayImageView.image = UIImage(named: "madrid-small")goUIbutton.setTitle("go Spain", for: .normal)}else if (sender.selectedSegmentIndex == 1){displayImageView.image = UIImage(named: "trip-italy-catania")goUIbutton.setTitle("go Italy", for: .normal)}else if (sender.selectedSegmentIndex == 2){displayImageView.image = UIImage(named:"trip-villach")goUIbutton.setTitle("go Austria", for: .normal)}else { displayImageView.image = UIImage(named: "london")goUIbutton.setTitle("go Uk", for: .normal)}}}import UIKitclass ThirdViewController: UIViewController {@IBOutlet weak var peopleCountLabel: UILabel!override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.}@IBAction func peopleUIStepper(_ sender: UIStepper) {print(sender.value)//peopleCountLabel.text = Int(sender.value).descriptionpeopleCountLabel.text = "\(Int(sender.value))"}}

--

--