2
我正在尝试将微调器添加到视图中,并使用以下代码对其进行动画处理。它在iOS 6中工作完全正常,但不会在iOS 7的微调不旋转CABasicAnimation无法在iOS7中工作
下面是创建与微调
- (CALayer *)spinnerLayer
{
CALayer *result = nil;
UIImage *spinnerImage = [UIImage imageNamed:@"spin.png"];
if (spinnerImage != nil)
{
CGSize size = [spinnerImage size];
CALayer *layer = [[CALayer alloc] init];
if (layer != nil)
{
[layer setFrame:CGRectMake(0.0, 0.0, size.width, size.height)];
[layer setContents:(id)[spinnerImage CGImage]];
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
if (anim != nil)
{
[anim setToValue:@(M_PI * 2.0)];
[anim setRepeatCount:INFINITY];
[anim setDuration:1.0];
[anim setFillMode:kCAFillModeBoth];
[layer addAnimation:anim forKey:@"Rotation"];
}
result = [[layer retain] autorelease];
[layer release];
}
}
return result;
}
链接(https://forums.raywenderlich.com/?f=2&t=9985)没有指向相关的讨论。它目前显示论坛索引页面 – xta