Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. final class TextCollectionViewCell: UICollectionViewCell {
  2. let textLabel: UILabel
  3.  
  4. override init(frame: CGRect) {
  5. textLabel = {
  6. let label = UILabel(frame: .zero)
  7. label.adjustsFontForContentSizeCategory = true
  8. label.font = UIFont.preferredFont(forTextStyle: .body)
  9. label.translatesAutoresizingMaskIntoConstraints = false
  10. return label
  11. }()
  12. super.init(frame: frame)
  13. contentView.addSubview(textLabel)
  14. NSLayoutConstraint.activate([
  15. textLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
  16. textLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
  17. textLabel.topAnchor.constraint(equalTo: topAnchor, constant: 8),
  18. textLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8)
  19. ])
  20. contentView.layer.borderColor = UIColor.darkGray.cgColor
  21. contentView.layer.borderWidth = 1
  22. contentView.layer.cornerRadius = 4
  23. }
  24.  
  25. required init?(coder aDecoder: NSCoder) {
  26. fatalError("init(coder:) has not been implemented")
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement