Friday, April 8, 2011

iPhone - UITextAlignmentRight in UILabel cuts some part of text

I am trying to display two labels on UITableViewCell, one with left-aligned text and another with right-aligned text. The cell with right-alignment of text is cut on the right by 1-2 pixels. I tried increasing the width of the UILabel but it does not make a difference.

The text appear fine in the simulator but on the device it gets cut towards the right.

Here's the image URL for reference (Long Text 3 is cut)

From stackoverflow
  • This can be overcome by using the autoResizingMask property of the UILabel with right alignment.

    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
    

    Hope that helps someone.

0 comments:

Post a Comment