UIViewAnimation with block

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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章