Skip to content

Instantly share code, notes, and snippets.

@pardel
Created October 3, 2016 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pardel/1b854935bae7bc1ffd8efe12f11d2121 to your computer and use it in GitHub Desktop.
Save pardel/1b854935bae7bc1ffd8efe12f11d2121 to your computer and use it in GitHub Desktop.
//: 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