A
A
artursk2015-10-13 16:55:09
iOS
artursk, 2015-10-13 16:55:09

Is it possible to change the location of the title in the button on Xcode?

Is it possible to change the location of the title (text) in the button on Xcode, through coding? So that not according to the standard in the center, top, bottom, left, right, but according to their coordinates.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ManWithBear, 2015-10-13
@ManWithBear

//располагаем текст сверху слева
[button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
[button setContentVerticalAlignment:UIControlContentVerticalAlignmentTop];

//двигаем текст вниз и вправо на 10 пикселей
[button setTitleEdgeInsets:UIEdgeInsetsMake(10.0f, 10.0f, 0.0f, 0.0f)];

Keep in mind that these paddings are added after calculating the size of the button and text. So after an excessive shift, the text may be cut off.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question