我在 ViewController B 中加载 ViewControllerA。它是一个小的动画角色,在一个更大的场景中。
在 ViewControllerA 内部,有一个旋转动画,如:
CAKeyframeAnimation *bobble = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
NSArray *times = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.25],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.75],
[NSNumber numberWithFloat:1.0],
nil];
[bobble setKeyTimes:times];
NSArray *values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:degreesToRadian(0)],
[NSNumber numberWithFloat:degreesToRadian(5)],
[NSNumber numberWithFloat:degreesToRadian(0)],
[NSNumber numberWithFloat:degreesToRadian(-5)],
[NSNumber numberWithFloat:degreesToRadian(0)],
nil];
[bobble setValues:values];
bobble.repeatCount = HUGE_VALF;
bobble.autoreverses = YES;
bobble.duration = 5.0;
bobble.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[self.view.layer addAnimation:bobble forKey:@"transform.rotation"];
它自己的 viewDidLoad 和 viewDidAppear 看起来像:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.view.center = CGPointMake(640, 201);
[self.view setAnchorPointAndReposition:CGPointMake(.7, .7)];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self bobble];
[NSTimer scheduledTimerWithTimeInterval:3. target:self selector:@selector(blinkFromTimer:) userInfo:nil repeats:YES];
}
在 iOS5+ 中,它加载和动画效果很好,在 iOS 4.3 中,它加载但看不到动画。
有什么见解吗?