代码之家  ›  专栏  ›  技术社区  ›  Pablo

从动画块中排除

  •  3
  • Pablo  · 技术社区  · 14 年前
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    ...
    [UIView commitAnimations];
    

    例如,我需要有条件地设置帧宽度的动画,以及其他必需的修改。我不能将代码从这个块中移出的原因,因为块中有一个函数调用。 如何从动画块中排除某些操作?

    2 回复  |  直到 9 年前
        1
  •  9
  •   ohho    14 年前

    结帐 setAnimationsEnabled :

    [UIView beginAnimations:@"Ani" context:NULL];
    [UIView setAnimationDuration:1.0];
      // some animations
    [UIView setAnimationsEnabled:NO];
      // animations disabled (put exclusions here)
    [UIView setAnimationsEnabled:YES];
      // some more animations
    [UIView commitAnimations];  
    
        2
  •  0
  •   EarlyRiser    9 年前

    以下是基于块的方法:

    [UIView performWithoutAnimation:^{
        view.frame = CGRectMake(...);
    }];