Created
March 31, 2022 17:21
-
-
Save selahattincincin/c45267e47c9b25c90a551a021f945263 to your computer and use it in GitHub Desktop.
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 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