Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created May 14, 2020 08:11
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 stevencurtis/c41c26a293186726116a8a66f86b13f3 to your computer and use it in GitHub Desktop.
Save stevencurtis/c41c26a293186726116a8a66f86b13f3 to your computer and use it in GitHub Desktop.
BlueViewLayout
class BlueViewLayout: UIView {
var myLabel = UILabel()
// init from code
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
// init from xib or storyboard
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
// common setup code
private func setupView() {
backgroundColor = .red
myLabel.text = "a"
myLabel.textAlignment = .center
self.addSubview(myLabel)
}
override func layoutSubviews() {
super.layoutSubviews()
myLabel.frame = self.bounds
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment