我的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;
}
}
}
标签是否无法转换?
一直在玩这个一个小时,没有任何事情发生 - .-
谢谢
-码
没有找到相关结果
已邀请:
1 个回复
悸翠疮武昏
应该是:
因为你想影响标签的不透明度,使其淡入或淡出。因此,为了使您的标签在5秒内从0.5到1.0的不透明度淡入,您将使用以下代码: