Tayo119
Tayo119

Reputation: 341

Remove extra bottom pading UILabel

Help me please. I don't know why the UILabel gets bottom padding, the text hasn't got any final space or break line.

Image

This is the code on cellForItemAt:

    let cell:PlaceCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "place_cell", for: indexPath) as! PlaceCollectionViewCell

    cell.lblTitle.attributedText = mPlace?.title?.styled(with: styleTitle!)
    cell.lblSubTitle.attributedText = mPlace?.excerpt?.styled(with: styleDescription!)
    cell.lblSubTitle.sizeToFit()
    cell.lblSubTitle.layoutEdgeInsets = .zero

And this is the text:

<p>apofkapfojqpofjqwp ofjkqpfojqwfpojfqw</p>

I'm using BonMot to remove te XML tags

I have already tested with ".zero" insets and "sizeToFits()"

This is storyboard where you can see the "numberOfLines" and constraints.

Storyboard

Upvotes: 1

Views: 3110

Answers (1)

Pushpendra
Pushpendra

Reputation: 1519

When you set it's constraint to what ever you want like from right, left top and bottom all you have set 10.

There is no Matter how much line you are using in your UILabel. Matter only does for this the bottom constraint for the last UILabel. As i can see in the image which you have uploaded you have three UILabel or may be more then...

So here do not use the bottom constraint for the last UILabel...

Check Image

And do not set height constraint to the UILabel...

Upvotes: 1

Related Questions