【问题标题】:UIView Animation Curves not working for some animationsUIView 动画曲线不适用于某些动画
【发布时间】:2016-04-13 15:13:49
【问题描述】:

我有一个应用程序,我在其中使用了很多动画,轻松进出曲线。我在所有情况下都使用此功能:UIView animateWithDuration:delay:options:animations:completion

所有这些动画都可以正常工作,但现在我正在尝试将一个添加到弹出的抽屉中,并且由于某种原因,这个特定的动画总是线性的:

[UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
    self.activityBar.view.frame = CGRectMake(0, self.activityBar.view.frame.origin.y, self.activityBar.view.frame.size.width, 20);
} completion:nil];

为什么这个动画是线性的,而其他具有相同选项的动画是弯曲的?

这是self.activityBar.view 的视图层次结构

-UIViewController
 -UIViewController
  -UIViewController (animation code lives here)
   -UIViewController (activityBar)
    -UIView (activityBar.view)

【问题讨论】:

    标签: ios objective-c animation uiview


    【解决方案1】:
    //Set old Frame for activityBar Here
    
    [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            [self.view layoutIfNeeded];
    //Update to the new frame 
    self.activityBar.view.frame = CGRectMake(0, self.activityBar.view.frame.origin.y, self.activityBar.view.frame.size.width, 20);
    
        } completion:^(BOOL finished) {
    
        }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 2012-02-26
      • 2015-01-30
      • 2012-01-04
      相关资源
      最近更新 更多