CAKeyframeAnimation for backgroundColor…导致崩溃

|| 我用此代码枚举一个数组,它崩溃了。我认为这是因为我包装的颜色不正确,但是如何传递它们呢?
    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\"];
    
已邀请:
        
    iValues = [NSArray arrayWithObjects:
               (id)iButton.backgroundColor.CGColor,
               (id)iButton.color.CGColor,
               (id)iButton.backgroundColor.CGColor,
               nil];
    
        要获得UIButton的颜色,可以执行以下操作: [iButton backgroundColor]; 您可能不需要这些东西:   [NSValue   valueWithBytes:iButton.backgroundColor                                 objCType:@encode(UIColor)],     

要回复问题请先登录注册