I have 2 buttons with the same width and height, also y-Achse centered. They differ only from text length. With iPhone 5, 6 and 6+ they look very well. But with iPhone 4s one button will do not more have the same front size as the other one and it is text will be not more centered. My question is if there is a method to adopt the font size of the 2 buttons so they will take together the same font with small value of font size of one button.
Asked
Active
Viewed 140 times
0
-
You can set your font size according to the main screen size, like : `[myButton.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:[UIScreen mainScreen].bounds.size.height/20]];` – Randy Jun 17 '15 at 12:18
-
Th problem is also the width because the have different text length – Fahem Issameddine Jun 17 '15 at 12:40
1 Answers
0
If I understand correctly, you want to use the same font size for both buttons, even when one of them has to reduce the size for the text to fit it.
Use something like this to reduce the size of the font on each button, until an appropriate size is found for both buttons. Take the minimum of the sizes you found, and use it on both buttons.

Community
- 1
- 1

Eran Goldin
- 980
- 12
- 21
-
you have understood correctly what i want to find. But should I also make configurations lile content hugging priority or content compression ? – Fahem Issameddine Jun 17 '15 at 12:19
-
It depends on what you want to achieve. If you want the buttons to change size based on constraints, then yes. If you want the buttons to keep their sizes and change only font size, then no. – Eran Goldin Jun 17 '15 at 14:19
-
I have achieved it on depend of the size of the iphone´s view – Fahem Issameddine Jun 17 '15 at 14:55