2013-12-13 33 views
2

在我的应用程序中,我有一个图像数组,每秒获取动画。
我用下面的代码,如何在iOS中的动画图像上放置一个按钮?

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
按钮的输出得到显示在图像的背景中。
但我想以显示它以前生产的图像

+0

使用** insertSubview:aboveSubview:* *或在** addSubview之后调用** addSubview:button **:animateImageView ** – onmyway133

+0

它的优良性能仍然可以起作用。看看你是否在xib中有一个图像视图,然后在那里手动添加按钮,并且也可以通过编程方式设置类似于图像视图的按钮框。 –

回答

0

如果你想要把在图像的顶部的按钮,你可以后调用以下方法addSubview:

[self.view bringSubviewToFront:button]; 
相关问题