UIView基于块的动画重绘

ran*_*dom 4 objective-c uiview uiviewanimation objective-c-blocks

我需要设置setAnimationBeginsFromCurrentState一个块.我找不到任何关于如何做的文档或示例.

我需要转换这个:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES]; //The problem
[UIView setAnimationDuration:kKeyboardAnimationDuration];
[self.view setFrame:viewFrame];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

进入一个区块以及设置setAnimationBeginsFromCurrentState属性.

Mic*_*lum 7

使用基于块的UIView动画时,您可以传递UIViewAnimationOptionBeginFromCurrentState给动画的选项.

[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
    [self.view setFrame:viewFrame];
}completion:^(BOOL done){
   //some completition
}];
Run Code Online (Sandbox Code Playgroud)