【问题标题】:UIButton with Animation Image doesn't showing带有动画图像的 UIButton 不显示
【发布时间】:2014-02-25 14:51:02
【问题描述】:

我发现了与带有动画图像的 UIButton 相关的帖子。 但是我没有找到任何解决方案。

这是我的代码。

UIImage *imageOne=[UIImage imageNamed:@"1Ads.png"];
UIImage *imageTwo=[UIImage imageNamed:@"2Ads.png"];
UIImage *imageThree=[UIImage imageNamed:@"3Ads.png"];

NSArray *arr = [[NSArray alloc] initWithObjects:imageOne,imageTwo,imageThree, nil];
self.btnAds.imageView.animationDuration = 7.0;
self.btnAds.imageView.animationImages = arr;
[self.btnAds.imageView startAnimating];

它没有在视图中显示任何内容。

我该怎么做?

【问题讨论】:

  • 尝试设置:animationRepeatCount。

标签: ios uibutton uiimage


【解决方案1】:

使用 UIButton 的 imageView 属性。您可以像这样创建动画:

[myButton setImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];
myButton.imageView.animationImages = [NSArray arrayWithObjects:
                              [UIImage imageNamed:@"1.png"],
                              [UIImage imageNamed:@"2.png"],
                              [UIImage imageNamed:@"3.png"],
                              [UIImage imageNamed:@"4.png"],
                              [UIImage imageNamed:@"5.png"],
                              nil];

myButton.imageView.animationDuration = 0.5;
[myButton.imageView startAnimating];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多