我想打一個按鈕,使紅色和綠色的背景開關,但我得到這個錯誤:預期的功能缺失return返回迅速
missing return in a function expected to return UIView
我很新的編碼,我已經搜索了一下,但我沒有找到任何東西。
語言:雨燕
我的代碼:
var timeLeft = 0
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
var buttonColor: UIView! {
timeLeft = 1
}
func update() {
if timeLeft > 0 {
view.backgroundColor = UIColor.greenColor()
}
else {
view.backgroundColor = UIColor.redColor()
}
timeLeft = timeLeft - 1
}
}
感謝幫助
看到這裏的問題:http://stackoverflow.com/questions/24689469/swift-error-missing-return-in-function – 2015-02-23 13:47:58