Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add padding to an UILabel? [duplicate]

Tags:

uilabel

iphone

The text inside an UILabel is smashed against the left and right borders. Is there an way of adding some inner padding to the UILabel, so that text won't touch the inner borders so closely?

like image 622
dontWatchMyProfile Avatar asked Apr 23 '10 22:04

dontWatchMyProfile


People also ask

How do I add padding to UILabel?

If you have created an UILabel programmatically, replace the UILabel class with the PaddingLabel and add the padding: // Init Label let label = PaddingLabel() label. backgroundColor = . black label.

How do I change my UILabel?

To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.

How do you label corner radius in Swift?

"label. layer. masksToBounds = true" is an important code, if you apply corner radius to a label and if it dosen't work than adding this will definitely add the corner radius to a particular label.. So this should be the correct answer..


1 Answers

Just adjust the position of the label (I'm not aware of any other method, although someone else might). If you have an issue with background colors (for instance), make the background a separate UIView and put the label on top of it.

like image 72
shosti Avatar answered Sep 24 '22 09:09

shosti