【问题标题】:Center of second animation not using new position第二个动画的中心不使用新位置
【发布时间】:2013-06-20 22:18:13
【问题描述】:

我在 iOS 中运行两个动画时遇到问题。首先,我试图通过更改第一个动画集中的帧将图像从屏幕底部移动到顶部,然后在完成时我试图通过变换比例来扩展对象的长度。但是由于某种原因,一旦第一个动画完成,对象就会回到屏幕底部的原始位置,并且不断增长的变换发生在屏幕外。谁能帮我这个?提前感谢您的帮助,这是我的代码:

CGRect fullview = CGRectMake(59, 102, 650, 150);
CGRect iconView = CGRectMake(59, 102, 290, 150);
CGRect textView = CGRectMake(349, 102, 360, 150);

[_profileBtn setEnabled:FALSE];
[_profileBtn setHidden:TRUE];
[UIView animateWithDuration:1 animations:^{  // animate the following:

    _profileIcon.frame = iconView; // move to new location
    _profileText.frame = textView; // move to new location
    _profileBackground.frame =fullview;

}completion:^(BOOL finished){
    [UIView animateWithDuration:1 animations:^{  // animate the following:           
        _profileBackground.transform = CGAffineTransformMakeScale(1, 5.64);
    }];


}];

【问题讨论】:

    标签: ios animation transform frame


    【解决方案1】:

    查看documentation 的 UIView 转换属性。具体来说,如果您调整变换,对象的框架会发生什么情况。我认为与其在 UIView 的变换上执行第二个动画,不如将其应用于其图层变换的比例。

    【讨论】:

    • 查看文档后,我仍然不知道我是否明白。你介意给我一个你在代码中谈论的例子吗?
    【解决方案2】:

    我想出了一个接近我想要的解决方案。这将同时进行平移和移动:

        CGRect iconView = CGRectMake(59, 102, 290, 150);
        CGRect textView = CGRectMake(349, 102, 360, 150);
        _profileIcon.frame = iconView; // move to new location
        _profileText.frame = textView; // move to new location
        CGAffineTransform scale = CGAffineTransformMakeScale(1, 5.00);
        CGRect fullview = CGRectMake(59, 40, 650, 150);
        _profileBackground.frame = CGRectApplyAffineTransform(fullview,scale);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 2017-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多