Skip to content

Instantly share code, notes, and snippets.

@selahattincincin
Created March 31, 2022 17:21
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 selahattincincin/c45267e47c9b25c90a551a021f945263 to your computer and use it in GitHub Desktop.
Save selahattincincin/c45267e47c9b25c90a551a021f945263 to your computer and use it in GitHub Desktop.
class EmptyStateView: UIView {
private lazy var messageLabel: UILabel = {
let label = UILabel()
label.text = "No one here...."
label.translatesAutoresizingMaskIntoConstraints = false
label.font = .systemFont(ofSize: 24, weight: .black)
label.textAlignment = .center
label.numberOfLines = 2
return label
}()
override init(frame: CGRect) {
super.init(frame: frame)
configureLayout()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func configureLayout() {
backgroundColor = .systemBackground
addSubview(messageLabel)
NSLayoutConstraint.activate([
messageLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor, constant: 16),
messageLabel.topAnchor.constraint(equalTo: topAnchor, constant: 16),
trailingAnchor.constraint(greaterThanOrEqualTo: messageLabel.trailingAnchor, constant: 16),
bottomAnchor.constraint(greaterThanOrEqualTo: messageLabel.bottomAnchor, constant: 16),
messageLabel.centerXAnchor.constraint(equalTo: centerXAnchor)
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment