Byte Byte - 3 months ago 9
Swift Question

Adjusting label accroding to its data in ios using Swift

I have a custom UITableViewCell design as

enter image description here

What I want to is that "points" label should come under the last digit in my Numbers label. Lets say I have 1990 value in my Numbers label the "points" labels should come uder the last digit "0" in this case.

How can I do this please guide me Thanks.


You can add a Horizontal Space between the points label and the number label with a negative value roughly equates the width of 1 character

For instance here: enter image description here

Here in this example the horizontal space is -30 while the font size of the number label is 61pt. You can see that it is roughly one character width. (Of course you can apply more complicated math if you please to get the exact value you desire or accommodates your design principle)

And with making sure that the number label does not have an explicit width constrain it will automatically expand to fit its contents and therefore pushing the points label appropriately. like this:

enter image description here