Answer the question
In order to leave comments, you need to log in
How to align the left edge of the title to the center of the button?
There are buttons that contain pictures and titles. Titles with different number of characters. Since initially the title can be set at the left edge of the button, the right edge and the middle of the button, due to the different length of the title in the buttons, the text is not displayed exactly relative to each other, which entails a shift in pictures.
I'm trying to align the text and picture of each button in the storyboard using the tyka adjusting by mm,
but on one size the phone is displayed perfectly evenly, but on other sizes everything floats ... It would be logical to tie the left edge of the title in each button to the middle of the button, and not the entire title to the middle ... Tell me how to do it ? Or are there any other options?
Screenshots to the question at the link, I publish the question from my mobile phone, I can’t upload screenshots:https://forum.swiftbook.ru/t/kak-vyravnit-levyj-kr...
Answer the question
In order to leave comments, you need to log in
The answer above, as I think it is kostilMaking ...
I have it implemented like this:
- (void)makeContentButtons:(UIButton *)button {
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
button.contentEdgeInsets = UIEdgeInsetsMake(0, 70, 0, 0);
}
Not quite sure what you have there.
But the first thing that comes to mind is to abandon the buttons, push the table there, build the cells normally, and catch the click on the cells of the table.
Another option is custom buttons with their own layout.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question