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..
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..
this is the solution
dispatch_async(dispatch_get_main_queue(), ^{
yourLabel.numberOfLines = 0;
[yourLabel sizeToFit];
});
In Swift:
yourLabel.lineBreakMode = NSLineBreakMode.ByClipping
yourLabel.text = yourString.stringByAppendingString("\n\n\n\n")