一做入、UIView動(dòng)畫
1草描、基礎(chǔ)動(dòng)畫
//標(biāo)記動(dòng)畫塊開始
[UIView beginAnimations:nil context:nil];
//定義動(dòng)畫加速和減速方式
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//以秒為單位指定動(dòng)畫時(shí)長(zhǎng)
[UIView setAnimationDuration:0.5];
//設(shè)置代理
[UIView setAnimationDelegate:self];
//動(dòng)畫結(jié)束后回調(diào)方法
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
/*視圖變化動(dòng)作在這里*/
//標(biāo)志動(dòng)畫塊的結(jié)束
[UIView commitAnimations];
2币喧、試圖切換的過渡動(dòng)畫
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.6];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:parentView cache:YES];
//在parentView執(zhí)行動(dòng)畫的時(shí)候,調(diào)換兩個(gè)視圖的位置,以達(dá)到視圖切換的效果
[parentView exchangeSubviewAtIndex:index1 withSubviewAtIndex:index2];
[UIView commitAnimations];
3、Block實(shí)現(xiàn)基礎(chǔ)動(dòng)畫
1.淡入動(dòng)畫
[UIView animateWithDuration:0.5 animations:^(void){
//動(dòng)畫開始執(zhí)行調(diào)用的
self.myView.alpha = 1.0;
}completion:^(BOOL finish) {
NSLog(@"動(dòng)畫結(jié)束");
}];
4混滔、Block實(shí)現(xiàn)試圖切換的過渡動(dòng)畫
UIViewAnimationOptions options = UIViewAnimationTransitionFlipFromRight;
[UIView transitionWithView:parentView duration:3.0f options:options animations:^{
[parentView exchangeSubviewAtIndex:page1Index withSubviewAtIndex:page2Index];
} completion:^(BOOL finished) {
NSLog(@"finished %d", finished);
}];