0
我想创建一个显示动画图像的按钮。我在this的帖子中读到了这个建议,我添加了一个UIImageView(带有一个animationImages数组)作为UIButton的子视图。我试图做到这一点,像这样: (动画1是在头部声明一个UIImageView对象)用UIImageView子视图显示动画图像的UIButton
- (void)viewDidLoad {
UIImage *image1 = [UIImage imageNamed:@"Good1.png"];
UIImage *image2 = [UIImage imageNamed:@"Good2.png"];
UIImage *image3 = [UIImage imageNamed:@"Bad1.png"];
NSArray *images = [[NSArray alloc] initWithObjects:image1, image2, image3, nil];
animation1.animationImages = images;
[images release];
[self.button1 addSubview:animation1];
[self.button1 bringSubviewToFront:animation1];
[button1 setNeedsDisplay];
animation1.animationDuration = 1;
animation1.animationRepeatCount = 3;
[animation1 startAnimating];
[super viewDidLoad];
}
但没有出现在按钮中。任何想法,我可能会出错?
此外,我希望它可以根据用户按下按钮时显示的图像调用不同的方法。我之前实现了这一点,但创建了一个图像数组,使用NSTimer将UIButton的背景图像设置为遍历这些图像,然后将按钮的图像数据与数组中的图像进行比较,调用另一个图像每个方法。这看起来效率不高!因此,我试图在子视图中循环显示图像。任何关于如何从按钮被按下时UIButton的UIImageView子视图中提取图像数据的建议将不胜感激:)
谢谢!
迈克尔
对不起,响应缓慢 - 我会给它一个去 - 谢谢! 有关如何提取UIImageView在按下按钮时显示的UIImage的任何想法? 干杯:) – Smikey 2010-08-03 18:10:01