0

I've been trying to create my app and something is bugging me very much,

I have images of what I am trying to achieve:
1)
enter image description here

2 )

enter image description here

number 1 shows what I am trying to do, the letters are "squeezed" together making the text appear tighter with a short width even though the letter sizing is big.

number 2 shows my attempt to achieve this, I tried multiple different ways to get that same look but failed for hours, does anyone have any suggestions or know how to make the text look like that in the first picture?

I appreciate any help, thank you!

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
Zouvv
  • 143
  • 1
  • 8
  • Show the code you used to try this. Nobody can help you with this amount of information. – Mundi Jul 24 '15 at 11:24

2 Answers2

0

The only way how to do it AFAIK is to use transform on UILabel, like this:

let widthTransform = 0.8 // Shrink label to 80% of its width
label.layer.transform = CATransform3DMakeScale(widthTransform, 1.0, 1.0);

Hope it helps!

Note* that transform work for about 30% of decrease (even less imo), then it just starts to look very bad. You can also change text spacing, but if you calculate it dynamically, you could end up with negative one and that looks terrible. The easiest way really is then just change of the design :)

Jiri Trecak
  • 5,092
  • 26
  • 37
  • This will mess with all text sizes information later, whole layouts may work in a wrong way. That's really not a good way to solve the issue as may lead to many UI problems. – Nat Jul 24 '15 at 12:16
  • That depends on situation, fe. if you are using autolayout, if your label has fixed width, it won't break anything. But all of the ideas are bad tbh, best is to avoid this kind of behavior altogether and just change layout / make more space. – Jiri Trecak Jul 24 '15 at 12:19
  • Why changing the text spacing is wrong? It's a designed way to do such things. One just have to calculate it properly. Transforming is more a "hacky way" than real solution. If you use autolayout and calculate height to be dynamic transforms will fail totally. Same with layoutSubviews. – Nat Jul 24 '15 at 12:23
  • you guys are both right, but this did in fact work. I appreciate your help, thanks guys! – Zouvv Jul 24 '15 at 12:46
  • I am just saying that it does what author wanted it to do, thats all. It is not best solution really :) Don't forget to mark some answer as accepted, so others know as well! (and have a nice day both of you) – Jiri Trecak Jul 24 '15 at 12:49
0

Options:

  1. You can decrease character spacing like in this answer and increase font size.

  2. Having fun with transformation on layer is really awful idea, as later you won't be able to get the height of text etc -> just everything will be working wrong.

  3. You can also just use different font.

Community
  • 1
  • 1
Nat
  • 12,032
  • 9
  • 56
  • 103