I am trying a to create a Youtube like app. I am not using IB in this project. The issue I am having is the text gets cut off when the sentence is too big to fit in one line. I want to display the first sentence without being cut off just like Original Youtube app. The code for UILabel is given below.
let titleLabel:UILabel = {
let label = UILabel()
label.text = "Linkin Park - Numb"
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 2
return label
}()
//constraints for titlelabel
//top
addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .Top, relatedBy: .Equal, toItem: thumbnailImageView, attribute: .Bottom, multiplier: 1, constant: 8))
//left
addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .Left, relatedBy: .Equal, toItem: profileImageView, attribute: .Right, multiplier: 1, constant: 8))
//right
addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .Right, relatedBy: .Equal, toItem: thumbnailImageView, attribute: .Right, multiplier: 1, constant: 0))
// height
titleLabelHeightConstraint = NSLayoutConstraint(item: titleLabel, attribute: .Height, relatedBy: .Equal, toItem: self, attribute: .Height, multiplier: 0, constant: 44)
addConstraint(titleLabelHeightConstraint!)
The following image can give the idea about what I meant above. My App
I am also posting the image of original Youtube App. The first sentence never gets cut off in original Youtube app. Youtube App
Is there any way I can show text just like Youtube in my app?