Skip to content

Instantly share code, notes, and snippets.

@dqhieu
Created September 10, 2017 08:02
Show Gist options
  • Save dqhieu/2a1fc38c88f809d3430743bedcf23972 to your computer and use it in GitHub Desktop.
Save dqhieu/2a1fc38c88f809d3430743bedcf23972 to your computer and use it in GitHub Desktop.
private func setupComponents() {
_titleLabel = UILabel(frame: .zero)
_titleLabel.textColor = UIColor.black
_titleLabel.numberOfLines = 0
_titleLabel.backgroundColor = UIColor.red
addSubview(_titleLabel)
_subTitleLabel = UILabel(frame: .zero)
_subTitleLabel.textColor = UIColor.black
_subTitleLabel.numberOfLines = 0
_subTitleLabel.backgroundColor = UIColor.green
addSubview(_subTitleLabel)
_contentLabel = UILabel(frame: .zero)
_contentLabel.textColor = UIColor.black
_contentLabel.numberOfLines = 0
_contentLabel.backgroundColor = UIColor.yellow
addSubview(_contentLabel)
_titleLabel.snp.makeConstraints { (make) in
make.leading.top.trailing.equalToSuperview()
make.height.greaterThanOrEqualTo(0)
}
_subTitleLabel.snp.makeConstraints { (make) in
make.top.equalTo(self._titleLabel.snp.bottom)
make.leading.trailing.equalToSuperview()
make.height.greaterThanOrEqualTo(0)
}
_contentLabel.snp.makeConstraints { (make) in
make.top.equalTo(self._subTitleLabel.snp.bottom)
make.leading.trailing.equalToSuperview()
make.bottom.equalToSuperview()
}
self.backgroundColor = UIColor.blue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment