Last active
April 13, 2019 02:15
-
-
Save laevandus/30fe1f0077cef957238d767c55ff26bf 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
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