ios - How can I enforce an UILabel to be wider than it should be, by 5 points? -


i have uilabel, has background color green. wraps text closely. need green background little wider text, approx 5 points. how can achieve this?

details

label created in storyboard , has horizontal spacing constraints. can ignore constraints guess, because have handled width.

suggested requirement

i guess need method can override in uilabel's subclass, increase width 5 points. knows method shoul override?

you may try subclassing of uilabel class , overriding below method -

- (void)drawtextinrect:(cgrect)rect {     uiedgeinsets insets = {0, 5, 0, 5};     [super drawtextinrect:uiedgeinsetsinsetrect(rect, insets)]; } 

hope !


Comments