微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有关CABasicAnimation的问题

如何解决有关CABasicAnimation的问题

|
- (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\"];

}
考虑上面的示例代码: 上面的代码示例编译时完全没有错误和警告,但是预期在1秒钟内旋转360度的\“ timeLabel \”根本不会移动。检查是否确实从控制台的NSLog()输出调用方法“ showCurrentTime”。上面的方法已经在电话模拟器和真实设备上进行了测试。出现相同的问题-一切正常,除了没有旋转...请帮助。     

解决方法

        试试
[CABasicAnimation animationWithKeyPath : @\"transform.rotation\"];
您忘记了旋转中的“ i” :)     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。