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
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") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment