如何使标签始终在动画之上

时间:2013-07-06 09:12:04

标签: ios animation label

我在我的ViewController中显示动画。并且动画图像是图像阵列。当我开始动画时,图像将覆盖我放在ViewController上的一个标签。如何在动画期间将标签保留在图像顶部? 下面是我的动画代码;

 CGRect frame = CGRectMake(0, 62, 325, 290);
NSMutableArray *animationImageArray = [NSMutableArray arrayWithCapacity:4];
for (int i=0;i<4;i++)
{
    NSString *imageName = [NSString stringWithFormat:@"radar0%d.png",i+1];
    UIImage *animationImage = [UIImage imageNamed:imageName];
    [animationImageArray addObject:animationImage];
}
UIImageView *animationImageView = [[UIImageView alloc]initWithFrame:frame];
animationImageView.animationImages = animationImageArray;
animationImageView.animationDuration = 3;
animationImageView.animationRepeatCount = 1;
[animationImageView startAnimating];
[self.view addSubview:animationImageView];

1 个答案:

答案 0 :(得分:0)

将UILabel添加到UIApplication的keyWindow,而不是控制器的视图:

UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow addSubview:myLabel];

或者,您可以在添加动画UIImageView之后将标签带到视图的正面:

[self.view bringSubviewToFront:myLabel];