#7 Light App
Published in
2 min readJul 28, 2018
這支是用touchesBegan去寫的,當營幕被touch了一下,uiView就會變顏色
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
程式碼如下:
@IBOutlet weak var changeView: UIView!var number = 0override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {number = number + 1switch number % 7 {case 0:changeView.backgroundColor = UIColor.redcase 1:changeView.backgroundColor = UIColor.orangecase 2:changeView.backgroundColor = UIColor.yellowcase 3:changeView.backgroundColor = UIColor.greencase 4:changeView.backgroundColor = UIColor.bluecase 5:changeView.backgroundColor = UIColor.purplecase 6:changeView.backgroundColor = UIColor.browndefault:changeView.backgroundColor = UIColor.blackbreak}
}
GitHub
如果覺得我文章寫的還不錯,就追隨、拍手或留言討論吧,謝謝你們。