Home > OS >  UiLabel text get cut off from Top
UiLabel text get cut off from Top

Time:10-05

i have a enter image description here

Here how i declared the properties :

@IBOutlet private weak var descriptionLabel: ExpandableLabel!

I tried different method but didn't help, Example:

descriptionLabel.lineBreakMode = .byCharWrapping
descriptionLabel.sizeToFit()
descriptionLabel.baselineAdjustment = .none

Someone please suggest how to solve that by not cutting off the text from top.

Constraints: enter image description here

CodePudding user response:

descriptionLabel.clipsToBounds = false

This solves the problem

CodePudding user response:

the label's (vertical) content compression resistance priority was not high enough, setting it to required (1000) fixed it.

or a quick hack

 override public func layoutSubviews() {
    super.layoutSubviews()
    var frame = self. descriptionLabel.frame
    frame.size.height  = 1.0
    self.descriptionLabel.frame = frame
}
  • Related