UITextView缩放和旋转后,文本消失

时间:2018-11-05 06:05:57

标签: ios uitextview uigesturerecognizer

我在UIPinchGestureRecognizer上添加了UIRotationGestureRecognizerUITextView。收缩或旋转时,将更改UITextView对象的transform属性。但是,如果我将其旋转一定角度并放大到一定比例,文本将突然消失。

如果我继续旋转它,文本可能会以某种角度重新出现。

有什么办法可以解决失踪案吗?

这就是我使用手势识别器方法所做的事情。

- (void)onPinchtextView:(UIPinchGestureRecognizer *)pinchGestureRecognizer {
CGFloat scale = pinchGestureRecognizer.scale;
if (pinchGestureRecognizer.state == UIGestureRecognizerStateChanged || pinchGestureRecognizer.state == UIGestureRecognizerStateBegan) {
    self.textView.transform = CGAffineTransformScale(self.textView.transform, scale, scale);
    pinchGestureRecognizer.scale = 1.f;
}

- (void)onRotatetextView:(UIRotationGestureRecognizer *)rotateGestureRecognizer {
    CGFloat rotation = rotateGestureRecognizer.rotation;
    if (rotateGestureRecognizer.state == UIGestureRecognizerStateChanged || rotateGestureRecognizer.state == UIGestureRecognizerStateBegan) {
        self.textView.transform = CGAffineTransformRotate(self.textView.transform, rotation);
        [rotateGestureRecognizer setRotation:0];
    }
}

0 个答案:

没有答案