将图像添加到ios中的“我的按钮”为蓝色
我的按钮中有一个gif,但它只显示为蓝色框将图像添加到ios中的“我的按钮”为蓝色,ios,objective-c,ios6,uibutton,Ios,Objective C,Ios6,Uibutton,我的按钮中有一个gif,但它只显示为蓝色框 (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { //[self setTitle:@"Register" forState:UIControlStateNormal]; [self setBackgroundColor:[UIColor whiteColor]]; [self setTitleColor:
(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;
}
图像已正确添加到xcode。提供了什么?iOS GIF图像不受支持,因此如果您希望使用动画设置图像,请执行以下代码:-
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];
有关更多信息,请查看以下有关iOS支持GIF的链接:-
不支持iOS GIF图像,因此如果您希望使用动画设置图像,请执行以下代码:-
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];
有关更多信息,请查看以下有关iOS支持GIF的链接:-
尝试设置[button backgroundimage],它将为您设置任何格式的图像尝试设置[button backgroundimage],它将为您设置任何格式的图像SDWebImage声称支持动画gif 请查看:
SDWebImage声称拥有动画gif支持 请查看:
尝试使用
UIImageView
显示gif。iOS不支持gifimages@chris你必须对问题的答案做出回应,因为这不是获得帮助的方式。atlist你给回复的用户谁给你的问题的答案。感谢您尝试使用UIImageView
显示gif。iOS不支持gifimages@chris你必须对问题的答案做出回应,因为这不是获得帮助的方式。atlist你给回复的用户谁给你的问题的答案。非常感谢。