IOS中通过Core Animation实现简单动画

//对UIImageView的旋转
//CATransaction
//    imageView.layer
    [CATransaction begin];
    [CATransaction setValue:[NSNumber numberWithFloat:1.0] forKey:kCATransactionAnimationDuration];
    //按Y轴旋转
    CABasicAnimation *FlipAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    FlipAnimation.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    //旋转按弧度M_PI,就是180度
    FlipAnimation.toValue= [NSNumber numberWithFloat:M_PI];
    FlipAnimation.duration=1;
    //旋转后保持状态
    FlipAnimation.fillMode=kCAFillModeForwards;
    FlipAnimation.removedOnCompletion=NO;
    [imageView.layer addAnimation:FlipAnimation forKey:@"flip"];
    [CATransaction commit];

另参考:

1、IOS中通过Core Animation实现简单动画

2、IOS----Core Animation介绍1



//    也可以通过对UIView.layer做矩阵做相应的变换达到动画的效果

//例如
 [UIView beginAnimations:nil context:NULL];
    CGAffineTransform moveTransform = CGAffineTransformMakeTranslation(180, 200);
    [imageView.layer setAffineTransform:moveTransform];
    imageView.layer.opacity = 1;
    [UIView commitAnimations];

另参考:

1、CGAffineTransform相关函数

2、转换矩阵

你可能感兴趣的:(IOS中通过Core Animation实现简单动画)