为什么这个CATransition不起作用?

时间:2012-03-12 00:24:35

标签: iphone ios core-animation

我正在尝试转换UILabel的文字:

CATransition *animation = [CATransition animation];
animation.duration = 4;
animation.type = kCATransitionReveal;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[label.layer addAnimation:animation forKey:nil];

label.text = resultDateStr;

这很好用。但是当我将它设置为kCATransitionFade时,它就会停止工作。在iOS 4.3和5.0上测试了吗?

2 个答案:

答案 0 :(得分:0)

试试这个

[CATransaction begin];
CATransition *animation = [CATransition animation];
animation.type = kCATransitionFade;
animation.duration = 3.50;

[self.view addSubview:mySecondUIView]

[[self.view layer] addAnimation:animation forKey:@"Fade"];
[CATransaction commit];

答案 1 :(得分:0)

验证您是否在主线程上执行此任务。