4

I have a UILabel with 4 lines in a UICollectionView. When there are fewer than 4 rows, I want the text to be on the top and not in the centre.

Thanks..

ghr
  • 505
  • 4
  • 8
mark jannet
  • 580
  • 1
  • 5
  • 12

2 Answers2

4

this is the solution

dispatch_async(dispatch_get_main_queue(), ^{
            yourLabel.numberOfLines = 0;
            [yourLabel sizeToFit];


        });
Mirko Catalano
  • 3,850
  • 2
  • 26
  • 39
1

In Swift:

yourLabel.lineBreakMode = NSLineBreakMode.ByClipping 
yourLabel.text = yourString.stringByAppendingString("\n\n\n\n")
thomasdao
  • 972
  • 12
  • 26