1

我有一个UISlider用于缩放imageView(而不是UIPinchGesture)并且我正在使用UIRotationGesture,它们都可以独立工作。缩放而不做旋转手势可以正常工作!但是一旦我执行旋转并且他们放大或缩小imageview它就会表现得很奇怪,因为它会失去旋转比例。(这就是我的猜测!)我该如何解决这个问题?

好吧,自从几天以来,我对这些数学问题都不太满意,而且我在论坛中搜索也找不到解决方案。请帮助我:)

对于缩放:(这里我不处理变换,因为我不确定)

-(void)scale:(UISlider *)sender
{
      float sliderValue = [sender value];
    CGRect newFrame = placeRing.frame;
    newFrame.size = CGSizeMake(sliderValue, sliderValue);
    placeRing.frame = newFrame;
}

对于旋转

- (void)twoFingersRotate:(UIRotationGestureRecognizer *)recognizer
{
    isRotated = TRUE;
    if ([recognizer state] == UIGestureRecognizerStateBegan || [recognizer state] == UIGestureRecognizerStateChanged) {
         rotation= recognizer.rotation;
    rotatedTransform = CGAffineTransformRotate([placeRing transform], [recognizer rotation]);
        placeRing.transform = rotatedTransform;
       [recognizer setRotation:0];
    }

   }
4

1 回答 1

1

旋转应用了使您用于调整视图大小的框架属性无效的变换。使用边界和中心属性进行缩放。

请参阅以下警告框:http: //developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816

-(void)scale:(UISlider *)sender
{
    float sliderValue = [sender value];
    placeRing.bounds = CGRectMake(0, 0, sliderValue, sliderValue);
}
于 2013-02-23T11:15:21.977 回答