Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将图像添加到ios中的“我的按钮”为蓝色_Ios_Objective C_Ios6_Uibutton - Fatal编程技术网

将图像添加到ios中的“我的按钮”为蓝色

将图像添加到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:

我的按钮中有一个gif,但它只显示为蓝色框

 (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你给回复的用户谁给你的问题的答案。非常感谢。