背景颜色的 CAKeyframeAnimation...导致崩溃
我用这段代码枚举一个数组,它崩溃了。我认为这是因为我错误地包裹了颜色,但是我应该如何传递它们呢?
CAKeyframeAnimation *iAnimation = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
NSArray *iTimes;
NSArray *iValues;
NSInteger iTag = iButton.tag;
iTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:(iTimeBlock * iTag)],
[NSNumber numberWithFloat:(iTimeBlock * iTag + 1)],
[NSNumber numberWithFloat:iTimeBlock * (iTag + 2)], nil];
iValues = [NSArray arrayWithObjects:
iButton.backgroundColor,
iButton.color, // my subclass has this property
iButton.backgroundColor, nil];
[iAnimation setKeyTimes:iTimes];
[iAnimation setValues:iValues];
[iAnimation setDuration:21.0];
[iButton.layer addAnimation:iAnimation
forKey:@"FlashColor"];
I enumerate an array with this code and it crashes. I think it is because I am wrapping the colors incorrectly, but how should I pass them?
CAKeyframeAnimation *iAnimation = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
NSArray *iTimes;
NSArray *iValues;
NSInteger iTag = iButton.tag;
iTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:(iTimeBlock * iTag)],
[NSNumber numberWithFloat:(iTimeBlock * iTag + 1)],
[NSNumber numberWithFloat:iTimeBlock * (iTag + 2)], nil];
iValues = [NSArray arrayWithObjects:
iButton.backgroundColor,
iButton.color, // my subclass has this property
iButton.backgroundColor, nil];
[iAnimation setKeyTimes:iTimes];
[iAnimation setValues:iValues];
[iAnimation setDuration:21.0];
[iButton.layer addAnimation:iAnimation
forKey:@"FlashColor"];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要获取 UIButton 的颜色,您可以这样做:
[iButton backgroundColor];
你可能不需要这个东西:
To get the color of a UIButton you can do like this :
[iButton backgroundColor];
you probably don't need this stuff :