
Untitled
By: a guest on
Jul 15th, 2012 | syntax:
None | size: 1.36 KB | hits: 17 | expires: Never
How to do 'serial' animation with GCD?
//customView.alpha = 1.0 here
[UIView animateWithDuration:1 animations:^{
customView.alpha = 0.3;
}
completion:^(BOOL finished){
// remove customView from super view.
}];
//(dispatch_queue_t)queue was created in other parts of the code
dispatch_sync(queue, ^{
[UIView animationWithDuration:animations:...];
});
- (void)methodThatIsRunWhenTheNotificationIsReceived {
// Do other stuff here I assume...
self.numberOfTimesToRunAnimation = self.numberOfTimesToRunAnimation + 1;
if ([self.numberOfTimesToRunAnimation == 1]) {
[self methodThatAnimates];
}
}
- (void)methodThatAnimates {
if (self.numberOfTimesToRunAnimation > 0) {
// Animation preparations ...
[UIView animateWithDuration:1
animations:^{
customView.alpha = 0.3;
}
completion:^(BOOL finished){
// Animation clean up ...
self.numberOfTimesToRunAnimation = self.numberOfTimesToRunAnimation - 1;
[self methodThatAnimates];
}];
}
}