Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MessageCell : UITableViewCell {
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- let label = UILabel()
- override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: style, reuseIdentifier: reuseIdentifier)
- label.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."
- label.textAlignment = .right
- label.lineBreakMode = .byWordWrapping
- label.numberOfLines = 0
- label.translatesAutoresizingMaskIntoConstraints = false
- backgroundColor = .clear
- contentView.addSubview(label)
- NSLayoutConstraint.activate([
- // constrain label top to contentView top (use contentView margins)
- label.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
- // constrain label bottom to contentView bottom (use contentView margins)
- label.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor),
- // constrain label trailing to contentView trailing (use contentView margins)
- label.trailingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor),
- // constrain label width to 80% of contentView width (use contentView margins)
- label.widthAnchor.constraint(equalTo: contentView.layoutMarginsGuide.widthAnchor, multiplier: 0.8),
- ])
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement