关于CABasicAnimation的问题

Sta*_*ley 0 iphone cocoa-touch objective-c

- (IBAction) showCurrentTime : (id) sender

{
    NSLog(@" --- showCurrentTime called --- ");

    NSDate *now = [NSDate date];

    static NSDateFormatter *formatter = nil;

    if (!formatter) 
    {
        formatter = [[NSDateFormatter alloc] init];
        [formatter setTimeStyle : NSDateFormatterLongStyle];
    }

    [timeLabel setText : [formatter stringFromDate : now]]; 

    // Create a basic animation

    CABasicAnimation *spin =
       [CABasicAnimation animationWithKeyPath : @"transform.rotaton"];


    // set transform values
    [spin setFromValue : [NSNumber numberWithFloat : M_PI * 0.0]];
    [spin setToValue   : [NSNumber numberWithFloat : M_PI * 2.0]];
    [spin setDuration  : 1.0];

    // Add animation object to the layer
    [[timeLabel layer] addAnimation : spin
                       forKey       : @"spinAnimation"];

}
Run Code Online (Sandbox Code Playgroud)

考虑以上示例代码:

上面的代码示例完全没有错误和警告编译,但"timeLabel",预计在1秒内旋转360度,根本不会移动.检查确实从控制台的NSLog()输出调用了方法"showCurrentTime".上述方法已在手机模拟器和真实设备上进行了测试.同样的问题出现了 - 一切都很好,除了没有旋转...请帮助.

Sas*_*cha 5

尝试 [CABasicAnimation animationWithKeyPath : @"transform.rotation"];

你在轮换中忘记了"我":)