略微占個(gè)坑做個(gè)筆記??
- (void)starRedPacketAnimation {
/** animationWithKeyPath的值:
transform.rotation.z 左右擺動(dòng)
transform.translation.x 左右移動(dòng)
transform.scale 比例轉(zhuǎn)化
transform.scale.x 寬的比例
transform.scale.y 高的比例
transform.rotation.x 圍繞x軸旋轉(zhuǎn)
transform.rotation.y 圍繞y軸旋轉(zhuǎn)
transform.rotation.z 圍繞z軸旋轉(zhuǎn)
*/
CABasicAnimation *momAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
// 起始值
momAnimation.fromValue = [NSNumber numberWithFloat:-1];
// 結(jié)束值
momAnimation.toValue = [NSNumber numberWithFloat:1];
// 一次動(dòng)畫的間隔
momAnimation.duration = 0.5;
// 重復(fù)次數(shù)(此處設(shè)置無限循環(huán)動(dòng)畫)
momAnimation.repeatCount = CGFLOAT_MAX;
// 設(shè)置動(dòng)畫完成時(shí),返回到原點(diǎn)
momAnimation.fillMode = kCAFillModeForwards;
// 動(dòng)畫在完成后是否相反執(zhí)行
momAnimation.autoreverses = YES;
// 離開此頁面之后 回來繼續(xù)動(dòng)畫
momAnimation.removedOnCompletion = NO;
[redPacketImgView.layer addAnimation:momAnimation forKey:@"animateLayer"];
}