iOS 核心动画

//基本动画 实现平移动/旋转/等
CABasicAnimation * anima=[CABasicAnimation animation];
anima.keyPath = @"position"; /transform.sacle /transform.remote
anima.toValue = [NSValue valueWithCGPoint:CGPointMake(200 , 200)];
anima.removedOnCompletion = NO;
anima.fillMode = kCAFillModeForwards;
anima.delegate= self;
[self.imgeView.layer addAnimation:anima forKey:nil];

// 实现旋转 按路径运动等
CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
anim.keyPath = @"position";
// anim.values = @[@(angle2Radon(-5)),@(angle2Radon(5)),@(angle2Radon(-5))];
anim.repeatCount = MAXFLOAT;
anim.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(30, 30, 100, 200)].CGPath;
[_imgeView.layer addAnimation:anim forKey:nil];

// 转场动画

NSString  *imageName  = [NSString stringWithFormat:@""];
_imgeView.image = [UIImage imageNamed:imageName];

CATransition *anima =[CATransition animation];
anima.type =@"cube";

// 这个有很多可以到晚上去查

[_imgeView.layer addAnimation:anima forKey:nil];

//动画组。同时实现平移动 旋转等

CAAnimationGroup * groupAnima = [CAAnimationGroup animation];

CABasicAnimation * scal = [CABasicAnimation animation];
scal.keyPath = @"position";
scal.toValue =[NSValue valueWithCGPoint:CGPointMake(100, 10)];



CABasicAnimation * postiton = [CABasicAnimation animation];
postiton.keyPath = @"transform.scale";
postiton.toValue =@(0.5);


groupAnima.animations = @[scal,postiton];

[self.imgeView.layer addAnimation:groupAnima forKey:nil];

//uiview 动画是要改变位置的
[UIView animateWithDuration:0.25 animations:^{
_imgeView.layer.position = CGPointMake(150, 100);
} completion:^(BOOL finished) {

}];

//核心动画其实这些位置数据是没有改变的

  • (void)animationDidStart:(CAAnimation *)anim{

}

// 动画结束。涂层

  • (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{

}

你可能感兴趣的:(iOS 核心动画)