如何将GIF
图片用作UIButton
图片背景?
UIImage *img1 = [UIImage imageNamed:@"btn_img1"];
UIImage *img2 = [UIImage imageNamed:@"btn_img2"];
UIImage *img3 = [UIImage imageNamed:@"btn_img3"];
// GIF ImageView
_btnGIF.imageView.animationImages = [[NSArray alloc] initWithObjects:img1, img2, img3, nil];
_btnGIF.imageView.animationDuration = 0;
[_btnGIF.imageView startAnimating];
//[_btnGIF setBackgroundImage:GIF forState:UIControlStateNormal];
答案 0 :(得分:1)
您需要使用图像启动按钮,以便正确创建它。
例如:
UIImage *img1 = [UIImage imageNamed:@"btn_img1"];
UIImage *img2 = [UIImage imageNamed:@"btn_img2"];
UIImage *img3 = [UIImage imageNamed:@"btn_img3"];
[_btnGIF setImage:img1 forState:UIControlStateNormal];
// GIF ImageView
_btnGIF.imageView.animationImages = [[NSArray alloc] initWithObjects:img1, img2, img3, nil];
_btnGIF.imageView.animationDuration = 0;
[_btnGIF.imageView startAnimating];