捏缩放UILabel

时间:2011-06-18 11:49:28

标签: ios objective-c uilabel uigesturerecognizer cgaffinetransform

我正在处理捏合手势,我正在缩放UILabel这样:

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

问题是当我放大(使标签变大)时它不会重绘,即它变得模糊。如何让它再次变得清晰?

1 个答案:

答案 0 :(得分:2)

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

如果您希望缩放标签的内容,请调整contentsScale:

CGFloat scaleFactor = ...

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