gpt4 book ai didi

ios - 在ios中将图像添加到我的按钮是蓝色的

转载 作者:行者123 更新时间:2023-12-01 18:19:29 24 4
gpt4 key购买 nike

我的按钮中有一个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的Bellow链接:-

Discussions

Display animated GIF in iOS

关于ios - 在ios中将图像添加到我的按钮是蓝色的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18504569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com