转自:http://www.jianshu.com/p/d42012d3588c
transform.scale = 比例轉換
transform.scale.x = 闊的比例轉換
transform.scale.y = 高的比例轉換
transform.rotation.z = 平面圖的旋轉
opacity = 透明度
margin = 布局
zPosition = 翻转
backgroundColor = 背景颜色
cornerRadius = 圆角
borderWidth = 边框宽
bounds = 大小
contents = 内容
contentsRect = 内容大小
cornerRadius = 圆角
frame = 大小位置
hidden = 显示隐藏
mask
masksToBounds
opacity
position
shadowColor
shadowOffset
shadowOpacity
shadowRadius
实例几种动画初始化:
- //界限
- CABasicAnimation *boundsAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"];
- boundsAnimation.fromValue = [NSValue valueWithCGRect: self.ViewTest.bounds];
- boundsAnimation.toValue = [NSValue valueWithCGRect:CGRectZero];
- //透明度变化
- CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
- opacityAnimation.fromValue = [NSNumber numberWithFloat:1.0];
- opacityAnimation.toValue = [NSNumber numberWithFloat:0.5];
- //位置移动
- CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
- animation.fromValue = [NSValue valueWithCGPoint: self.ViewTest.layer.position];
- CGPoint toPoint = self.ViewTest.layer.position;
- toPoint.x += 180;
- animation.toValue = [NSValue valueWithCGPoint:toPoint];
- //旋转动画
- CABasicAnimation* rotationAnimation =
- [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];//"z"还可以是“x”“y”,表示沿z轴旋转
- rotationAnimation.toValue = [NSNumber numberWithFloat:(22 * M_PI) * 3];
- // 3 is the number of 360 degree rotations
- // Make the rotation animation duration slightly less than the other animations to give it the feel
- // that it pauses at its largest scale value
- rotationAnimation.duration = 3.0f;
- rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; //缓入缓出
- //rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
- //缩放动画
- CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
- scaleAnimation.fromValue = [NSNumber numberWithFloat:0.0];
- scaleAnimation.toValue = [NSNumber numberWithFloat:1.0];
- scaleAnimation.duration = 3.0f;
- scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- //组合动画
- CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
- animationGroup.duration = 3.0f;
- animationGroup.autoreverses = YES; //是否重播,原动画的倒播
- animationGroup.repeatCount = NSNotFound;//HUGE_VALF; //HUGE_VALF,源自math.h
- [animationGroup setAnimations:[NSArray arrayWithObjects:rotationAnimation, scaleAnimation,boundsAnimation, nil nil]];
- //将上述动画编组应用
- [self.ViewTest.layer addAnimation:animationGroup forKey:@"animationGroup"];

本文介绍如何使用CABasicAnimation和CAAnimationGroup等类创建复杂的UI动画效果,包括位置移动、透明度变化、旋转和平移等多种动画类型,并展示了如何通过组合不同类型的动画来达到更丰富的视觉效果。
365

被折叠的 条评论
为什么被折叠?



