@IBOutlet weak var title: UILabel! {
didSet {
label.textColor = UIColor.redColor()
label.font = UIFont.systemFontOfSize(20)
label.backgroundColor = UIColor.blueColor()
}
}
It's also possible to both set a value and initialize it:
private var loginButton = UIButton() {
didSet(oldValue) {
loginButton.addTarget(self, action: #selector(LoginController.didClickLogin), forControlEvents: .TouchUpInside)
}
}