我正在尝试做一个简单的 2 帧动画UIButton
。我知道使用该UIButton's
imageView.animationImages
属性可以做到这一点-将其设置为数组并为其设置动画。但是当我这样做时,什么都没有出现。仅供参考,我已经检查了 buttonImages 数组,它确实包含我想要显示的图像。有什么想法我哪里出错了吗?
NSArray *buttonImages = bookDoc.book.buttonImages;
UIImage *bookImage = bookDoc.thumbImage;
UIButton *bookButton = [UIButton buttonWithType:UIButtonTypeCustom];
bookButton.frame = CGRectMake(0, 0, bookImage.size.width, bookImage.size.height);
//[bookButton setBackgroundImage:bookImage forState:UIControlStateNormal];
bookButton.imageView.animationImages = buttonImages;
bookButton.imageView.animationDuration = 0.5;
bookButton.imageView.animationRepeatCount = INFINITY;
[bookButton addTarget:self action:@selector(bookButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[bookButton.imageView startAnimating];