[英]how to make a label always on top of animation
我在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];
將UILabel添加到UIApplication的keyWindow中,而不是添加到控制器的視圖中:
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow addSubview:myLabel];
另外,您可以在添加動畫的UIImageView
之后將標簽帶到視圖的前面:
[self.view bringSubviewToFront:myLabel];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.