如何在iOS中的动画图像上放置一个按钮?

时间:2013-12-13 09:36:06

标签: ios xcode uiimageview uibutton

在我的应用程序中,我有一个图像阵列,每秒都会动画一次 我使用了以下代码,

 animateArrayImages = [NSArray arrayWithObjects:
                   [UIImage imageNamed:@"gallery-img-1.png"],
                   [UIImage imageNamed:@"gallery-img-2.png"],nil];
animateImageView.animationImages = animateArrayImages;
animateImageView.animationDuration = 1.0f;
animateImageView.animationRepeatCount = 0;
[animateImageView startAnimating];
UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(20, 20, 20, 20)];
[self.view addSubview:button];  

但我得到这样的输出 enter image description here
该按钮将显示在图像的背景中 但我想在图像中显示它

1 个答案:

答案 0 :(得分:0)

如果您想将按钮置于图像顶部,可以在addSubview:

之后调用以下方法
[self.view bringSubviewToFront:button];