It won't hurt to try

Swift - type of parameter 본문

iOS/study

Swift - type of parameter

yongki.doki 2019. 12. 1. 17:10

toggle

//
//  ViewController.swift
//  HelloWorld
//
//  Created by YONGKI LEE on 2019/11/30.
//  Copyright © 2019 Brave Lee. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    var backgroundColorToggleFlag = false
    
    @IBOutlet weak var helloWorldLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    @IBAction func buttonTapped(_ sender: UIButton) {
        view.backgroundColor = backgroundColorToggleFlag ? .yellow : .blue
        _ = changeText(s1: "hello yellow world", "hello blue world")
        backgroundColorToggleFlag = !backgroundColorToggleFlag
    }
    
    func changeText(s1 scene1: String, _ scene2: String) -> String {
        helloWorldLabel.text = backgroundColorToggleFlag ? scene1 : scene2
        return ""
    }
}

 

class ViewController: UIViewController {

 

    var backgroundColorToggleFlag = false

    

    @IBOutlet weak var helloWorldLabel: UILabel!

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view.

    }

 

    @IBAction func buttonTapped(_ sender: UIButton) {

        view.backgroundColor = backgroundColorToggleFlag ? .yellow : .blue

        _ = changeText(s1: "hello yellow world", "hello blue world")

        backgroundColorToggleFlag = !backgroundColorToggleFlag

    }

    

    func changeText(s1 scene1: String, _ scene2: String) -> String {

        helloWorldLabel.text = backgroundColorToggleFlag ? scene1 : scene2

        return ""

    }

}

300x250
300x250

'iOS > study' 카테고리의 다른 글

Swift - shortcut  (0) 2019.12.01
Comments