Options inside begin animation and context

69 views Asked by At

I was studying about begin animation with UIView, usually in most tutorials they always use the same syntax:

[UIView beginAnimations:nil context:NULL];

I see in the code that inside the beginAnimation we can put a nsstring, and in context a void function, right? For that I do this:

[UIView beginAnimations:@"Will Start" context:@selector(start)];

-(void)start{

NSLog(@"Animation Running");

}

But the nsstring 'will start' was not showing to me, and the void function 'start' don't called. I do not know if I'm doing it in the wrong way, but what do those options BeginAnimation of NSString type and the type context of type void? Could someone give me an example?

1

There are 1 answers

0
Jadar On

It looks like you don't quite understand how the beginAnimations:context: method works. First of all, animationId is an NSString that just identifies the animations. Second, the data you pass to context is really just any data you want. A function pointer, an object, etc.

So what you do after calling [UIView beginAnimations:context:] is send the different setAnimation messages to set properties, change the view values to the values (position, color, alpha) you ultimately want to get to, and finally send the [UIView commitAnimations] message.

A good tutorial that explains this in more detail is here.