Reputation: 25701
I have a gif in my button, but it displays as just blue box.
(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
//[self setTitle:@"Register" forState:UIControlStateNormal];
[self setBackgroundColor:[UIColor whiteColor]];
[self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
[self setImage:[UIImage imageNamed:@"Person.gif"] forState:UIControlStateNormal];//setting image on button.
}
return self;
}
The image was added correctly to xcode. What gives?
Upvotes: 1
Views: 1105
Reputation: 4762
SDWebImage claims to have Animated gif support!
Check it out:
https://github.com/rs/SDWebImage
Upvotes: 0
Reputation: 49720
iOS GIF image not supported so if you wish to do set Image With Animation do like bellow code:-
UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image1.png"],
[UIImage imageNamed:@"image2.png"],
[UIImage imageNamed:@"image3.png"],
[UIImage imageNamed:@"image4.png"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[yourButton addSubview: animatedImageView];
For more Check this Bellow link about iOS suported GIF:-
Upvotes: 3
Reputation: 409
Try to set [button backgroundimage] and it will set any format of image to you
Upvotes: 1