Tuesday, December 7, 2010

How to use a block-based animation methods



According to apple's document,

Use of this method (such as "setAnimationWillStartSelector""commitAnimations") is discouraged in iPhone OS 4.0 and later. You should use the block-based animation methods instead.

Here is an example of using block-based animation methods.

{

notifyView.alpha = 0; //the status before animation
[UIView animateWithDuration:1.0
      animations:^ {
           notifyView.alpha = 1.0;
      }

      completion:^(BOOL finished) {
           [UIView animateWithDuration:1.0
                  animations:^ {
                       notifyView.alpha = 0;
                  }

                  completion:^(BOOL finished) {
                         ;
                  }];
      }];
}

Enif


No comments:

Post a Comment