I want to be able to increase/decrease the size of several the label/button fonts on my storyboard by the same amount. As far as I know sizes can be changed when selected (though as labels or buttons separately) and adjusted but each is updated by one font value not say a percentage. Ideally I'd like to select all labels and buttons and enter a value to times them by (e.g 1.4x). Is there definitely no way of doing this?
I used the label multipliers to create percentage view sizes and auto shrink to resize the text to be proportionally sized.
Related
I have five ui labels for one view. All of them have variable text content. To prevent truncating I have to use Autoshrink text size.
My ui labels are aligned in x axis top to bottom.
The problem is; when autoshrinking, all ui labels have different font sizes.
Is there a way to equalize font sizes of all ui labels when autoshrink.
I use interface builder autolayout constraints.
Thank you.
You could loop through your labels, find the smallest text size and then set that text size to all of them. That way, you know they'll all fit and have the same text size. You would have to do this programmatically. Alternatively, you could dynamically change the size of your UILabels based on the number of characters it holds times some constant factor. That way, the autoshrink should set the same size for each the text in each of the labels.
The image shows a 3x3 grid which is a vertical stackview, which contains 3 horizontal stackviews, which contain 3 buttons each. The top horizontal stackview has a correctly sized set of numbers within it(just by setting the font size to 80). The other two do not.
I want the numbers to take up the same amount of space on all devices so every number on each button is the same relative size on every device. This must be done programmatically! Not in IB... I cant find much info on this topic so even a link would be helpful please.
I have a multiline UILabel that I'd like to look similar on different devices (iPhone only). If it was a single line, I'd simply place the auto layout constraints and enable Autoshrink and set the Minimum Font Scale.
The height of the label is dynamic is calculated based on text. To do that, I need the font, which should also be dynamic. The hack I could do is place an invisible label, and set the text I want to fit in a single line into it and calculate the font, but it seems too hacky.
Another thing I'm not that familiar with are size classes. But from what I've read, the same class is shared between all portraits, meaning 3.5, 4, 4.7 and 5.5 inch devices would be bound to the same class, therefore I couldn't use the separate font value?
How would I implement the 'font scaling' for multiline labels so I'm getting similar look on different screen sizes?
If by similar look you mean that the same words appear on each line, I don't think it's possible.
If the label height is dynamic based on the amount of text, the label will simply expand to the height required to show the text with the specified font size.
Font scaling only kicks in when there is not enough space to display the text with the specified font size. Therefore, you must constrain the height or number of lines.
I was able to approximate this using a multiline UILabel with font scale of .5. I set an Equal Heights constraint between it and its superview, with a multiplier of .25. See screenshots below.
In this approach, you would have to dynamically change the Equal Heights multiplier based on the amount of text you have.
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.
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.
I have multiple labels in the storyboard using the any X any Resolution as follows:
Now I have added constraints to the best of my knowledge to force the labels to reposition when an iphone simulator is used and the following happens.
What I would like to happen is have the labels remain the same distance apart from each other proportionally and just resize their font size. So If we were to divide the Iphone screen into thirds Days would occupy the first 3rd, months the 2nd, and Years the 3rd. I thought maybe using aspect ratio for constraints would work but I got the same effect of the labels bunching on top of each other. It looks like they maintain the constraint of distance from the edges but they wont resize themselves to keep the ratio.
Thanks
If you want to keep same distance between each of them, one way of achieving it is:
Give all of them equal widths constraint. and set leading and trailing constraint to zero. Align all labels to centre horizontally.
This way, you wont need to change the font size..
But, however, if you still want to change font, go to attributed inspector for label and under auto shrink: change fixed font size to minimum font size and set it to appropriate value, say 14.