1
那么初始化值有什么好的经验法则。我使用Swift 2.0,并且只是好奇于如果我要在代码中的某个点设置10个值,创建该类以便在初始化时设置10个值,或者稍后应该执行该值,这很好。编程初始化
let button = Button(frame: CGRect, backgroundColor: UIColor, cornerRadius: Float, shadowPath: CGPath)
或者
let button = Button(frame: CGRect)
button.backgroundColor = UIColor.blackColor()
button.layer.cornerRadius = 2.0
button.layer.shadowPath = UIBeizerPath(rect: self.bounds).CGPath
哪一个是更好的做法?