2

Slider习惯ResizeRotate-

对于旋转 -

 CGAffineTransform transform = editingView.transform;
  transform =  CGAffineTransformMakeRotation(sliderVal * 2*M_PI / 30);
  editingView.transform = transform;

对于调整大小-

CGAffineTransform t = CGAffineTransformMakeScale(sliderVal/30, sliderVal/30);
  CGPoint center = editingView.center; 
  [UIView animateWithDuration:0.5
                   animations:^{
                      editingView.transform = t;
                     editingView.center = center;
                   }
                   completion:^(BOOL finished) {

                   }];

使用上面的代码,两者都可以正常工作。

但我必须resize旋转视图,或者旋转调整大小的视图。

我看到许多建议来自不同的行为,因为我正在使用CGAffineTransformMakeRotation, CGAffineTransformMakeScale,如果我使用CGAffineTransformScaleCGAffineTransformRotation那么我的问题将得到解决。

问题是当我使用时CGAffineTransform缩放不正确,View从屏幕上消失。

4

2 回答 2

5

您正在使用editingView.transform线设置视图的转换矩阵。

您应该更改旋转代码:

CGAffineTransform transform = editingView.transform;
transform =  CGAffineTransformMakeRotation(sliderVal * 2*M_PI / 30);
editingView.transform = CGAffineTransformConcat(editingView.transform, transform);

并调整大小:

CGAffineTransform t = CGAffineTransformMakeScale(sliderVal/30, sliderVal/30);
CGPoint center = editingView.center; 
[UIView animateWithDuration:0.5
                   animations:^{
                      editingView.transform = CGAffineTransformConcat(editingView.transform,t);
                      editingView.center = center;
                   }
                   completion:^(BOOL finished) {

                   }];

CGAffineTransformConcat您一起添加 2 个变换矩阵,这样您就不会丢失旧的变换。您可以使用CGAffineTransformIdentity重置转换。

于 2013-04-23T20:34:53.407 回答
3
        CGAffineTransform translate = CGAffineTransformMakeTranslation(self.webView.frame.origin.x,self.webView.frame.origin.y - self.webView.frame.size.height * 0.25);
        CGAffineTransform scale = CGAffineTransformMakeScale(0.6, 0.6);
        CGAffineTransform transform =  CGAffineTransformConcat(translate, scale);
        transform = CGAffineTransformRotate(transform, degreesToRadians(-10));

        [UIView beginAnimations:@"MoveAndRotateAnimation" context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
            [UIView setAnimationDuration:2.0];

            editingView.transform = transform;

        [UIView commitAnimations];

试试这样...

于 2013-04-19T10:14:32.107 回答