我的UILabel上没有动画

我为一些图像写了一些动画,它很有效。它几乎是相同的动画,但这次是在UILable上。但似乎没有任何东西。标签绘制但是当我调用动画方法时,文本不会改变/移动。
-(void) bounceText
{

NSLog(@"Bounce Text");
CABasicAnimation *grow;
grow = [CABasicAnimation animationWithKeyPath:@"growText"];
grow.timingFunction = [CAMediaTimingFunction 
    functionWithName:kCAMediaTimingFunctionLinear];
grow.toValue = [NSNumber numberWithFloat:3.0];
grow.fromValue = [NSNumber numberWithFloat:0.1];
grow.repeatCount = 10;
grow.fillMode = kCAFillModeForwards; 
grow.removedOnCompletion = YES;
grow.duration = 5.0;
grow.autoreverses = NO;
grow.delegate = self;


CABasicAnimation *fade;
fade = [CABasicAnimation animationWithKeyPath:@"fade"];
fade.fromValue = [NSNumber numberWithFloat:0.5];
fade.toValue = [NSNumber numberWithFloat:1.0];
fade.duration = 5.0;
CALayer *layer = [CALayer layer];
hintsLabel.layer.transform=CATransform3DTranslate(CATransform3DIdentity, 0, 0,50);   

[CATransaction begin];
[hintsLabel.layer addSublayer:layer];
[hintsLabel.layer addAnimation:grow forKey:@"growTheText"];
[layer addAnimation:fade forKey:@"fadeText"];
[CATransaction commit]; 
}
调用方法并向标签添加文本
 -(void) drawHints
 {
if (gameState == SHOWCARD)
{
    hintsLabel.layer.zPosition = 5;
    hintsLabel.text = @"It's your turn, select a button!";
    if (!bounce)
    {
    [self bounceText];
        bounce = YES;   
    }
}
}
标签是否无法转换? 一直在玩这个一个小时,没有任何事情发生 - .- 谢谢 -码     
已邀请:
这里的主要问题是您没有指定要设置动画的属性。 CAPropertyAnimation的文档为animationWithKeyPath:方法声明了以下内容:   要动画的属性的关键路径。 我不是100%确定你想用动画实现什么,但你有以下代码:
fade = [CABasicAnimation animationWithKeyPath:@"fade"];
应该是:
fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
因为你想影响标签的不透明度,使其淡入或淡出。因此,为了使您的标签在5秒内从0.5到1.0的不透明度淡入,您将使用以下代码:
    CABasicAnimation *fade;
fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
fade.fromValue = [NSNumber numberWithFloat:0.5];
fade.toValue = [NSNumber numberWithFloat:1.0];
fade.duration = 5.0;

[hintsLabel.layer addAnimation:fade forKey:@"fade"];
    

要回复问题请先登录注册