我有一个我正在尝试为学校创建的 iPhone 游戏,但我遇到了一些麻烦。我创建了一个动画 UIImage 用作背景。问题是,这是我所到的最远的地方。我无法在 ImageView 上方显示任何按钮、文本或标签。我在 View 控制器中将它设置为 ImageView 位于底部的位置,以便所有其他对象都可以出现在上方。有谁知道我在这里做错了什么或者我可以添加什么可以解决这个问题?我已经包含了创建动画的代码。
- (void)viewDidLoad
{
// 创建将执行动画的视图 UIImageView* YourImageView = [[UIImageView alloc] initWithFrame:self.view.frame];
// load all the frames of our animation
YourImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Star-Field 1.png"],
[UIImage imageNamed:@"Star-Field 2.png"],
[UIImage imageNamed:@"Star-Field 3.png"],
[UIImage imageNamed:@"Star-Field 4.png"],
[UIImage imageNamed:@"Star-Field 5.png"],
[UIImage imageNamed:@"Star-Field 6.png"],
[UIImage imageNamed:@"Star-Field 7.png"],
[UIImage imageNamed:@"Star-Field 8.png"],
[UIImage imageNamed:@"Star-Field 9.png"],
[UIImage imageNamed:@"Star-Field 10.png"],
[UIImage imageNamed:@"Star-Field 11.png"],
[UIImage imageNamed:@"Star-Field 12.png"],
[UIImage imageNamed:@"Star-Field 13.png"],
[UIImage imageNamed:@"Star-Field 14.png"],
[UIImage imageNamed:@"Star-Field 15.png"],
[UIImage imageNamed:@"Star-Field 16.png"],
[UIImage imageNamed:@"Star-Field 17.png"],
[UIImage imageNamed:@"Star-Field 18.png"], nil];
// all frames will execute in 1.75 seconds
YourImageView.animationDuration = 0.5;
// repeat the animation forever
YourImageView.animationRepeatCount = 0;
// start animating
[YourImageView startAnimating];
// add the animation view to the main window
[self.view addSubview:YourImageView];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}