スパルタエンコーディングクラブ-IMS第1週目


SWIFTの基本文法から簡単なFlashアプリを作成します.授業と教案資料は非常に詳しく,フォローしやすい.😆
懐中電灯の開閉動作を実現しました.以下はコードと結果画面です.
import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var label: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    @IBAction func onButtonClicked(_ sender: Any) {
        view.backgroundColor = UIColor(red: 0.96, green: 0.78, blue: 0.78, alpha: 1.00)
        label.textColor = UIColor.black
        imageView.image = UIImage(systemName: "flashlight.on.fill")
    }
    
    @IBAction func offButtonClicked(_ sender: Any) {
        view.backgroundColor = UIColor(red: 0.13, green: 0.13, blue: 0.39, alpha: 1.00)
        label.textColor = UIColor.white
        imageView.image = UIImage(systemName: "flashlight.off.fill")
    }
}