【问题标题】:iOS scale down animationiOS 缩小动画
【发布时间】:2015-09-23 08:42:07
【问题描述】:

当用户点击它时,我试图放大一个圆形的个人资料 imageview,然后当他点击屏幕上的其他任何地方时,imageview 必须恢复到正常大小。两个方向的缩放都必须是动画的。

这是我用来放大图像视图的代码:

    CGRect frame = CGRectMake(0, 0, 200, 200);
    imageView.frame = frame;
    imageView.transform = CGAffineTransformMakeScale(0, 0);
    [UIView animateWithDuration:0.5 animations:^{
        imageView.transform = CGAffineTransformMakeScale(1, 1);
    }];

恢复正常大小的代码:

    CGRect frame = CGRectMake(0, 0, 50, 50);
    imageView.frame = frame;
    imageView.transform = CGAffineTransformMakeScale(1, 1);
    [UIView animateWithDuration:0.5 animations:^{
        imageView.transform = CGAffineTransformMakeScale(0, 0);
    }];

按比例放大工作正常,但按比例缩小没有动画效果。它只是消失了。有人可以帮忙吗?

【问题讨论】:

    标签: ios animation imageview transform


    【解决方案1】:

    尝试不设置图像视图的框架,只设置像这样的变换来展开:

    [UIView animateWithDuration:0.5 animations:^{
            _settingsProfilePlaceholderImageView.transform = CGAffineTransformMakeScale(2, 2);
        }];
    

    签约:

    [UIView animateWithDuration:0.5 animations:^{
            _settingsProfilePlaceholderImageView.transform = CGAffineTransformMakeScale(1, 1);
        }];
    

    【讨论】:

      【解决方案2】:

      在第二个动画中试试这个:

      CGRect frame = CGRectMake(0, 0, 50, 50);
      self.imageView.frame = frame;
      self.imageView.transform = CGAffineTransformMakeScale(4, 4);
      [UIView animateWithDuration:0.5 animations:^{
      
              self.imageView.transform = .identity
      }];
      

      【讨论】:

      • 感谢您的回复。但是,行为仍然相同。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 2011-01-09
      • 2015-06-04
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      相关资源
      最近更新 更多