IPhone: keep text looking good after applying zoom?

I apply a scale transformation to a UIView that draws a number. (The number is literally drawn using drawInRect, there is no UILabel in the field of view.) A large-scale conversion makes the view smaller by a few bits ... say, 80% less.

The resulting number looks a bit "stocky." Is there a way that I can keep my text beautiful and smooth, how should it look like?

+3
source share
2 answers

The problem is that your scale simply scales on the rendered (raster) text, which makes it blurry. One way is to change the font size of the text according to the size of the container before scaling it, or even completely scale out and simply change the font size. See This Related Question .

The results depend on how you scale the view. Perhaps just changing the font size is not enough, and you need to stretch the selected text. If so, you will have to come up with a different approach .

I know that you are not using UILabel, but install myLabel.adjustsFontSizeToFitWidth = YESthe dimensional trick for you if you decide to go this route.

+3
source

My decision:

  lbl.layer.shouldRasterize = YES;
  lbl.layer.rasterizationScale = 0.375f;

set shouldRasterize .

0

Source: https://habr.com/ru/post/1748219/


All Articles