//CABasicAnimation
[blackView.layer addAnimation:[self opacityForever_Animation:3.0] forKey:@"key"];
//UIView Animation
[self animationRevealFromBotton:100];
transform.scale.x 宽的比例转换
transform.scale.y 高的比例转换
transform.rotation.z 平面圆的旋转
opacity 透明度
margin 在视图中展示内容的大小
zPosition 屏幕上层次的前后顺序
backgroundColor 背景颜色
cornerRadius 圆角
borderWidth 边的宽度
bounds layer的边界矩阵, 与frame类似contents 内容, 例如:图片的变化 contentsRect 内容可使用layer的大小frame 视图的frame矩阵hidden 隐藏状态 mask 遮挡背景和内容显示的透明度 masksToBounds 决定子layer是否从layer的边界中剪除position layer在其父layer中对应的位置shadowColor 阴影颜色shadowOffset 阴影偏移量shadowOpacity 阴影透明度shadowRadius 阴影圆角
- (CABasicAnimation *)opacityForever_Animation:(float)time
//永久闪烁的动画:渐变
{
//参数必须是layer的属性“属性”
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"backgroundColor"];
//属性的值的变换
// animation.fromValue=[NSNumber numberWithFloat:1.0];
// animation.toValue=[NSNumber numberWithFloat:3.0];
//位置变换 点对点
animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(125, 125)];
animation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2)];
animation.autoreverses=YES;
//持续时间
animation.duration=time;
//重复次数
animation.repeatCount=FLT_MAX;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
- (void)animationRevealFromBotton:(float)duration
{
[UIView animateWithDuration:duration animations:^{
blackView.transform = CGAffineTransformMakeScale(0.001, 0.001);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.70, 0.40, 0.80)];
animation.duration = 0.45;
animation.repeatCount = FLT_MAX;
[blackView.layer addAnimation:animation forKey:nil];
} completion:^(BOOL finished) {
[UIView animateWithDuration:duration animations:^{
blackView.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
}];
}