Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27153

iOS constraints make width of button more bigger then content text

I create all my constraints programmatically for my UI controls. So my button has a text: title

So if I don't set any restriction for width of the button, the app will create for me button based on text width, and this works fro me.

But I want to add few extra padding at left and right sides. How can I do it?

Upvotes: 1

Views: 314

Answers (1)

bobnoble
bobnoble

Reputation: 5824

Use the contentEdgeInsets property of UIButton, e.g.:

`yourButton.contentEdgeInsets = UIEdgeInsetsMake(0.f, 10.f, 0.f, 10.f);`

will add 10 points to the left and right edges.

Upvotes: 3

Related Questions