例如:
UIView *rotationViewX = [[UIView alloc]initWithFrame:CGRectMake(20, 100, 70, 70)]; rotationViewX.backgroundColor = VIEW_COLOR; [self.view addSubview:rotationViewX]; CABasicAnimation *rotationAnimationX = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"]; rotationAnimationX.beginTime = 0.0; rotationAnimationX.toValue = @(2*M_PI); rotationAnimationX.duration = 1.5; rotationAnimationX.repeatCount = HUGE_VALF; [rotationViewX.layer addAnimation:rotationAnimationX forKey:@"rotationAnimationX"];基础动画常用的keypath: 设定动画的属性和说明:
另还有弹性动画,波浪效果,火苗效果,详见demo: https://github.com/ZJQian/AnimationDemo/tree/master
共同学习,共同进步!
新闻热点
疑难解答