CABasicAnimation之animationWithKeyPath方法

来源:互联网 发布:淘宝商家客服人工服务 编辑:程序博客网 时间:2024/05/16 18:45

CABasicAnimation中可以用animationWithKeyPath类方法来创建动画.其中keyPath的值有以下若干.

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

另附模仿音乐播放器的动画代码如下:

/// 添加动画- (void)addAnimation{        CABasicAnimation *monkeyAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];    monkeyAnimation.toValue = [NSNumber numberWithFloat:2.0 *M_PI];    monkeyAnimation.duration = 20.0f;    monkeyAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];    monkeyAnimation.cumulative = NO;    monkeyAnimation.removedOnCompletion = NO; //No Remove    monkeyAnimation.fillMode = kCAFillModeForwards;    monkeyAnimation.repeatCount = FLT_MAX;    [self.imageView.layer addAnimation:monkeyAnimation forKey:@"AnimatedKey-ratation"];    [self.imageView stopAnimating];    self.imageView.layer.speed = 0.0;}

效果图



0 0
原创粉丝点击