1

このコードで配列を列挙すると、クラッシュします。色を間違ってラッピングしているからだと思いますが、どうすれば合格できますか?

    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"];
4

2 に答える 2

1
    iValues = [NSArray arrayWithObjects:
               (id)iButton.backgroundColor.CGColor,
               (id)iButton.color.CGColor,
               (id)iButton.backgroundColor.CGColor,
               nil];
于 2011-05-30T19:04:58.033 に答える
0

UIButtonの色を取得するには、次のようにします。

[iButton backgroundColor];

あなたはおそらくこのようなものを必要としないでしょう:

[NSValue valueWithBytes:iButton.backgroundColor objCType:@encode(UIColor)]、

于 2011-05-30T16:51:01.417 に答える