Ios 将UIView的一侧缩放/设置动画以使其更小?-CGAffineTransformMakeScale

Ios 将UIView的一侧缩放/设置动画以使其更小?-CGAffineTransformMakeScale,ios,cocoa-touch,core-animation,uiviewanimation,cgaffinetransform,Ios,Cocoa Touch,Core Animation,Uiviewanimation,Cgaffinetransform,我想设置UIView的动画,使其右侧变小,然后再回来。点击此UIView中的UIButton时将触发此动画。下面是我想要的快速模型-UIView将从状态1>状态2>状态1: 它看起来像是被推到了一边 这是我为另一个动作编写的代码——这使UIView变得越来越小,再次变得越来越大,好像它被推到了中心,而不是侧面 self.myView.transform = CGAffineTransformMakeScale(0.95,0.95); self.myView.alpha = 1.f; [UIV

我想设置UIView的动画,使其右侧变小,然后再回来。点击此UIView中的UIButton时将触发此动画。下面是我想要的快速模型-UIView将从状态1>状态2>状态1:

它看起来像是被推到了一边

这是我为另一个动作编写的代码——这使UIView变得越来越小,再次变得越来越大,好像它被推到了中心,而不是侧面

self.myView.transform = CGAffineTransformMakeScale(0.95,0.95);
self.myView.alpha = 1.f;

[UIView beginAnimations:@"button" context:nil];
[UIView setAnimationDuration:0.5];
self.myView.transform = CGAffineTransformMakeScale(1,1);
self.myView.alpha = 1.0f;
[UIView commitAnimations];
如何应用相同的效果,但仅适用于右侧?任何帮助都将不胜感激,谢谢

根据这一点,你不需要进行透视变换,例如,我对我链接的问题做了一些修改

  CATransform3D perspectiveTransform = CATransform3DIdentity;
  perspectiveTransform.m34 = 1.0 / -500;
  perspectiveTransform = CATransform3DRotate(perspectiveTransform, 40.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);

  [UIView animateWithDuration:0.4 animations:^{
    self.myView.layer.transform = perspectiveTransform;

  }];
编辑2返回到原始版本

 - (void)startAnimation:(id)sender
  {
     CATransform3D perspectiveTransform = CATransform3DIdentity;
     perspectiveTransform.m34 = 1.0 / -500;
     perspectiveTransform = CATransform3DRotate(perspectiveTransform, 40.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
     [UIView animateWithDuration:1.4 animations:^{
     self.myView.layer.transform = perspectiveTransform;
     }completion:^(BOOL finished) {

      CATransform3D originalPerspectiveTransform = CATransform3DIdentity;
      [UIView animateWithDuration:0.9 animations:^{
         self.myView.layer.transform = originalPerspectiveTransform;
        }];
     }];

  }
根据这一点,你不需要进行透视变换,例如,我从我链接的问题中修改了一点

  CATransform3D perspectiveTransform = CATransform3DIdentity;
  perspectiveTransform.m34 = 1.0 / -500;
  perspectiveTransform = CATransform3DRotate(perspectiveTransform, 40.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);

  [UIView animateWithDuration:0.4 animations:^{
    self.myView.layer.transform = perspectiveTransform;

  }];
编辑2返回到原始版本

 - (void)startAnimation:(id)sender
  {
     CATransform3D perspectiveTransform = CATransform3DIdentity;
     perspectiveTransform.m34 = 1.0 / -500;
     perspectiveTransform = CATransform3DRotate(perspectiveTransform, 40.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
     [UIView animateWithDuration:1.4 animations:^{
     self.myView.layer.transform = perspectiveTransform;
     }completion:^(BOOL finished) {

      CATransform3D originalPerspectiveTransform = CATransform3DIdentity;
      [UIView animateWithDuration:0.9 animations:^{
         self.myView.layer.transform = originalPerspectiveTransform;
        }];
     }];

  }

这是透视变换,不能用仿射变换完成。你需要围绕Y轴旋转,这是使用这种类型的矩阵无法实现的。我如何更改它以使此效果成为可能?你可以尝试将视图转换为图像并对其应用过滤器。试试这个@user1118321哦,我确实想转换显示UIImage的UIImageView(分别称为myImageView和myImage)。它们只是在UIView中。这是一个透视变换,不能用仿射变换来完成。你需要绕Y轴旋转,而这是用这种类型的矩阵无法完成的。我如何更改它才能实现这种效果?你可以尝试将视图转换为图像并对其应用过滤器。试试这个@user1118321哦,我确实想转换显示UIImage的UIImageView(分别称为myImageView和myImage)。它们只是在一个UIView中。非常感谢,它成功了!还有一件事-我如何让它回到它通常的位置?就像我在原始问题中发布的代码一样,当我点击中间的按钮时,它会回到它原来的大小/位置。在这种情况下,我如何让它回到它原来的透视图(请看我在《凤凰社》上发表的素描)。我不知道该怎么做:谢谢,珊珊:)我真的很感谢你的帮助!非常感谢,它成功了!还有一件事-我如何让它回到它通常的位置?就像我在原始问题中发布的代码一样,当我点击中间的按钮时,它会回到它原来的大小/位置。在这种情况下,我如何让它回到它原来的角度(请看我在《凤凰社》上贴的素描)我不知道该怎么做:谢谢你的帮助!