UIViewAnimation with block

来源:互联网 发布:王克晶java年薪多少 编辑:程序博客网 时间:2024/05/07 23:13

UIViewAnimation with block

| No Comments | No TrackBacks
原文地址 :http://iphone.ipsw.info/2010/06/uiviewanimation-with-block.html

UIViewAnimationWithBlocks使用block,动画结束后不需要使用回调方法,相比UIViewAnimation 方式要简洁很多


- (void)setSelectedVeg:(id)sender

{    

    [selectedVegetableIcon setAlpha:0.0];

    

    [UIView animateWithDuration:0.4

                     animations: ^{

                         float angle = [self spinnerAngleForVegetable:sender];

                         [vegetableSpinnersetTransform:CGAffineTransformMakeRotation(angle)];

                     } 

                     completion:^(BOOL finished) {

                         [selectedVegetableIcon setAlpha:1.0];

                     }];


}

以上代码来自WWDC2010 iPlant PlantCareViem.m


UIViewAnimation style Animation

- (void)setSelectedVeg:(id)sender

{    

    [selectedVegetableIcon setAlpha:0.0];

[UIView beginAnimations:@"setSelectedVeg" context:nil];

float angle = [self spinnerAngleForVegetable:sender];

[vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];

[UIView setAnimationDuration:0.4];

[UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(done)];

[UIView commitAnimations];

}

-(void)done

{

[selectedVegetableIcon setAlpha:1.0];

}

No TrackBacks

TrackBack URL: http://iphone.ipsw.info/mt/mt-tb.cgi/312

Leave a comment

Sign in to comment.