Don_Mag icon

Untitled

Don_Mag | PRO | 08/30/19 02:11:45 PM UTC | 0 ⭐ | 1096 👁️ | Never ⏰ | []
Swift |

1.63 KB

|

None

|

0 👍

/

0 👎

 
 
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),
            ])
 
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎