App개발 01

asdasd·2021년 6월 13일
0

앱개발 초기

목록 보기
1/1

내가 작성한 손전등 앱 코드

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var label: UILabel!
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}
@IBAction func onButtonClicked(_ sender: Any) {
    label.text = "On"
    view.backgroundColor = UIColor.white
    imageView.image = UIImage(systemName:"flashlight.on.fill")
    label.textColor = UIColor.black
    
}

@IBAction func offButtonClicked(_ sender: Any) {
    label.text = "OFF"
    view.backgroundColor = UIColor(red: 10 / 255.0, green: 40 / 255.0, blue: 210 / 255.0, alpha: 1)
    imageView.image = UIImage(systemName:"flashlight.off.fill")
    label.textColor = UIColor.white
    
    
}

}

배우면서 알게된 오류들
label.text를 변경할 때 길이에 따라서 ...로 표시되거나 변경이 되거나 하는 것 같다.

profile
공부 기록

0개의 댓글