random
random

Reputation: 8608

UIView block based animation redraw

I need to set setAnimationBeginsFromCurrentState in a block. I can't find any documentation or example on how to do it.

I need to convert this:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES]; //The problem
[UIView setAnimationDuration:kKeyboardAnimationDuration];
[self.view setFrame:viewFrame];
[UIView commitAnimations];

Into a block as well as set the setAnimationBeginsFromCurrentState property.

Upvotes: 4

Views: 742

Answers (1)

Mick MacCallum
Mick MacCallum

Reputation: 130222

When using block based UIView animation you can pass UIViewAnimationOptionBeginFromCurrentState to the animation's options.

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

Upvotes: 7

Related Questions