Created
May 14, 2020 08:11
-
-
Save stevencurtis/c41c26a293186726116a8a66f86b13f3 to your computer and use it in GitHub Desktop.
BlueViewLayout
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
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