Created
October 3, 2016 15:22
-
-
Save pardel/1b854935bae7bc1ffd8efe12f11d2121 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
class AView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
customInitialisation() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
customInitialisation() | |
} | |
var label: UILabel { | |
let label = UILabel(frame: CGRect(x: 10, y: 10, width: 100, height: 30)) | |
label.font = UIFont.systemFont(ofSize: 24.0) | |
label.text = "my label" | |
return label | |
} | |
} | |
extension AView { | |
func customInitialisation() { | |
addSubview(label) | |
backgroundColor = .red | |
label.backgroundColor = .blue | |
label.textColor = .white | |
} | |
} | |
let view = AView(frame: CGRect(x: 0, y: 0, width: 300, height: 300)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment