ios - 缩放/动画UIView的一侧变小? -CGAffineTransformMakeScale

标签 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;

[UIView beginAnimations:@"button" context:nil];
[UIView setAnimationDuration:0.5];
self.myView.transform = CGAffineTransformMakeScale(1,1);
self.myView.alpha = 1.0f;
[UIView commitAnimations];

如何将相同的效果应用到右侧?任何帮助将不胜感激,谢谢!

最佳答案

根据这个question,例如,您不需要进行“透视变换”,就对我链接的问题进行了一些修改

  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;
        }];
     }];

  }

关于ios - 缩放/动画UIView的一侧变小? -CGAffineTransformMakeScale,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23748876/

相关文章:

iphone - 委托(delegate)方法仅在按下 5 次左右的按钮后触发?

ios - 路径应用程序时间轴实现

iOS 在应用程序启动时动画 subview ?

ios - 从 xib 文件加载的自动调整 View

ios - 发送 10000 多个推送通知,但并非所有设备都收到

objective-c - 拆分 RACSignal 以消除状态

ios - 当主视图缩小时, subview 无法正确设置动画

objective-c - 可以在 c 结构中使用 CATextLayer 吗?

ios - viewWillAppear 和 viewDidAppear 之间的延迟

ios - NSDateFormatter格式化后错误的字符串