Llg Llg - 1 month ago 10
Swift Question

Add padding between label and its border

I have in my swift application some labels that should have border. I added border to my label but I want to have more spaces between the label and its border.

How can I do that?

Answer

Try this:

myLabel.frame.size.width = myLabel.intrinsicContentSize.width + 10
myLabel.frame.size.height = myLabel.intrinsicContentSize.height + 10
myLabel.textAlignment = .center
Comments