Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class TextCollectionViewCell: UICollectionViewCell {
- let textLabel: UILabel
- override init(frame: CGRect) {
- textLabel = {
- let label = UILabel(frame: .zero)
- label.adjustsFontForContentSizeCategory = true
- label.font = UIFont.preferredFont(forTextStyle: .body)
- label.translatesAutoresizingMaskIntoConstraints = false
- return label
- }()
- super.init(frame: frame)
- contentView.addSubview(textLabel)
- NSLayoutConstraint.activate([
- textLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
- textLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
- textLabel.topAnchor.constraint(equalTo: topAnchor, constant: 8),
- textLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8)
- ])
- contentView.layer.borderColor = UIColor.darkGray.cgColor
- contentView.layer.borderWidth = 1
- contentView.layer.cornerRadius = 4
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement