看我就會(huì)動(dòng)畫(huà)了:鏈接: https://pan.baidu.com/s/1dE9St4d 密碼: bb4c
翻轉(zhuǎn)動(dòng)畫(huà)
//開(kāi)始動(dòng)畫(huà)
[UIView beginAnimations:nil context:nil];
//設(shè)置時(shí)常
[UIView setAnimationDuration:1];
//設(shè)置動(dòng)畫(huà)淡入淡出
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//設(shè)置代理
[UIView setAnimationDelegate:self];
//設(shè)置翻轉(zhuǎn)方向
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView:self.myView cache:YES];
//動(dòng)畫(huà)結(jié)束
//當(dāng)動(dòng)畫(huà)執(zhí)行結(jié)束,執(zhí)行animationFinished方法
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
[UIView commitAnimations];
旋轉(zhuǎn)動(dòng)畫(huà)
//創(chuàng)建一個(gè)CGAffineTransform transform對(duì)象
CGAffineTransform transform;
//設(shè)置旋轉(zhuǎn)度數(shù)
transform = CGAffineTransformRotate(manImageView.transform,M_PI/6.0);
//動(dòng)畫(huà)開(kāi)始
[UIView beginAnimations:@"rotate" context:nil ];
//動(dòng)畫(huà)時(shí)常
[UIView setAnimationDuration:2];
//添加代理
[UIView setAnimationDelegate:self];
//獲取transform的值
[manImageView setTransform:transform];
//關(guān)閉動(dòng)畫(huà)
[UIView commitAnimations];
偏移動(dòng)畫(huà)
[UIView beginAnimations:@"move" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
//改變它的frame的x,y的值
manImageView.frame=CGRectMake(100,100, 120,100);
[UIView commitAnimations];
翻頁(yè)動(dòng)畫(huà)
[UIView beginAnimations:@"curlUp" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//指定動(dòng)畫(huà)曲線(xiàn)類(lèi)型,該枚舉是默認(rèn)的,線(xiàn)性的是勻速的
//設(shè)置動(dòng)畫(huà)時(shí)常
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
//設(shè)置翻頁(yè)的方向
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:manImageView cache:YES];
//關(guān)閉動(dòng)畫(huà)
[UIView commitAnimations];
縮放動(dòng)畫(huà)
CGAffineTransform transform;
transform = CGAffineTransformScale(manImageView.transform,1.2,1.2);
[UIView beginAnimations:@"scale" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[manImageView setTransform:transform];
[UIView commitAnimations];
取反的動(dòng)畫(huà)效果是根據(jù)當(dāng)前的動(dòng)畫(huà)取他的相反的動(dòng)畫(huà)
CGAffineTransform transform;
transform=CGAffineTransformInvert(manImageView.transform);
[UIView beginAnimations:@"Invert" context:nil];
[UIView setAnimationDuration:2];//動(dòng)畫(huà)時(shí)常
[UIView setAnimationDelegate:self];
[manImageView setTransform:transform];//獲取改變后的view的transform
[UIView commitAnimations];//關(guān)閉動(dòng)畫(huà)