问题描述
|
- (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” :)