Make UILabel height so it fits the characters it contains exactly (with autolayout)

I've seen that UILabel intrinsic size doesn't seem to fit exactly the characters it contains.

As you can see in the image, labels have some margin on top and bottom. I can make "Subtitle" get closer to "TITLE" using baseline (title.baseline ==, but I would also want to align "TITLE" to its parent top.

I would like to use autolayout constraints if possible.


Quick Fix

If your font size is constant for labels, you can try subclassing UILabel and override - (CGSize)intrinsicContentSize

-(CGSize)intrinsicContentSize {
    CGSize intrinsicSize = [super intrinsicContentSize];
    intrinsicSize.height -= 8; // Works good for system font size 17.0
    return intrinsicSize;

You might need to play with intrinsicSize.height -= 8; to get desired output.

Need Your Help

How to prevent fragmentation of MySQL data files?

mysql defragmentation

I think this question was asked many times, but searching for it I have found only some notes in some responses.

SVN: Branch and reintegrate is not working with updated server

svn mergeinfo

I am working with a Subversion server that was recently upgraded to version 1.7. I am using the command-line Linux client 1.7.10.