block例子!

-(void)categoryAction:(UIButton*)button
{
    //动画
    [UIView animateWithDuration:0.2
                     animations:
     ^{
         [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
         //执行动作
         _bgImageView.frame = rect[button.tag - BASE_TAG ];}
     
                     completion:
     ^(BOOL finished){
         //动画执行完了之后的动作
         
         for (UIView* view in _categoryScroller.subviews)
         {
             if ([view isMemberOfClass:[UIButton class]])
             {
                 UIButton* subButton = (UIButton*)view;
                 if (subButton.tag == button.tag)
                 {
                     [subButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                     
                 }
                 else
                 {
                     [subButton setTitleColor:[UIColor colorWithWhite:1.0 alpha:0.6] forState:UIControlStateNormal];
                 }
             }
             
         }
         
         [self resetSelectedData: button.tag - BASE_TAG];
         //[_categoryTableView reloadData];
         [[UIApplication sharedApplication] endIgnoringInteractionEvents];
     }];
    
    
}

 

posted @ 2013-01-09 17:15  六界剑仙  阅读(98)  评论(0)    收藏  举报