捏合缩放 UILabel

发布于 2024-11-16 02:04:37 字数 221 浏览 5 评论 0原文

我正在处理捏合手势,并且正在缩放 UILabel,如下所示:

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

问题是当我放大(使标签更大)时,它不会重新绘制自身,即它变得模糊。怎样才能让它再次锋利呢?

I'm handling a pinch gesture, and I am scaling a UILabel like 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心凉 2024-11-23 02:04:37

发生这种情况的原因是变换应用于视图层的渲染位图。

如果您想让标签的内容缩放,也可以调整contentsScale:

CGFloat scaleFactor = ...

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

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 );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文