简体   繁体   中英

how to make a label always on top of animation

i am displaying an animation in my ViewController. and the animation images are an array of images. when i start the animation, the images will cover one label i put on the ViewController. what can i do to keep the label on top of the images during the animation? Below is my animation code;

 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];

Add the UILabel to the UIApplication's keyWindow, rather than to the controller's view:

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

Alternatively, you can bring your label to the front of the view after adding the animated UIImageView :

[self.view bringSubviewToFront:myLabel];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM