ios - How do I prevent text from being cut off like in UITextView? -
i have uilabel , uitextview both same text (the string "snellroundhand", in snell roundhand bold font, point size 21). text in uitextview appears correctly, uilabel has text cut off on left , right sides. how text in label appear properly?

some notes:
- expanding frame of label won't work because might solve cutoff issue on right side of text not on left side.
- i can't take cheap way out , center text; text must stay @ whatever alignment in right now.
- the reason can't change uitextviews because app processing in background , crashes whenever instantiates uitextview. i'm hoping can around issue using uilabel instead render text.
in ios 6, nice new feature of uilabel supports attributed strings. attributed strings can include paragraph margins. can add margins string, ensuring there space between edges of label , drawing of string.
this section of book has sample code adds margins string drawn in uilabel:
http://www.apeth.com/iosbook/ch23.html#_attributed_strings
if want run on system earlier ios 6, can subclass uilabel force text drawn inset edges of label, shown in code (also book):
- (void)drawtextinrect:(cgrect)rect { [super drawtextinrect:cgrectinset(rect, 5.0, 5.0)]; }
Comments
Post a Comment