开发者

Pinch-to-zoom UILabel

开发者 https://www.devze.com 2023-03-14 00:53 出处:网络
I\'m handling a pinch gesture, and I am scaling a UILabel like开发者_如何学Python this: CGFloat factor = sender.scale;

I'm handling a pinch gesture, and I am scaling a UILabel like开发者_如何学Python this:

CGFloat factor = sender.scale;
view.transform = CGAffineTransformScale(view.transform, factor, factor);

The problem is when I zoom-in (make the label larger) it wont redraw itself, i.e. it becomes blurry. How do I make it sharp again?


The reason this happens is that transforms are applied to the rendered bitmap of the view's layer.

If you want to have the label's contents scaled adjust the contentsScale, too:

CGFloat scaleFactor = ...

view.layer.contentsScale = [UIScreen mainScreen].scale + scaleFactor;
view.transform           = CGAffineTransformMakeScale( scaleFactor, scaleFactor );
0

精彩评论

暂无评论...
验证码 换一张
取 消