Plain text being cut off at bottom in iOS, how to fix in xCode?

11,289

Solution 1

If your using something like a UILabel it means you will need to increase the vertical height of that element.. Either in code or in interface builder.

If you are doing it in code you can get the label to resize itself to fit the contents by calling sizeToFit..

[myLabel sizeToFit];

Alternatively you could measure the size to the string by using sizeWithAttributes: then change the size of the label accordingly.

Solution 2

Updating this one for Swift 3.x in a UITableViewController.

In cellForRowAtIndexPath after the problematic label is set, but before the cell is returned from the method, add a line something like this:

cell.myLabelWhoseCharactersLikegyqGetCutOff.sizeToFit()
Share:
11,289
user3108698
Author by

user3108698

Updated on July 18, 2022

Comments

  • user3108698
    user3108698 almost 2 years

    I noticed in my iOS app, for text that are using a system font with size 20 pt or more, the bottom of text is being cut off.

    For example, the bottom portion of the letters y, g, p, and g are being cut off.

    How do I fix this in Xcode?