0

我创建了一个 GIF,它基本上是飘落的雪粒,并且有一个透明的背景。因此,我可以在应用程序上的其他 PNG 和图像上流过雪。问题是应用程序加载并且 GIF 显示为全白。不知道为什么,因为我在制作时给了它透明度。如果我降低 Xcode 中的 alpha,我仍然看不到我的旧 PNG(通常的背景图像)。

这是在我的 ViewController.m

- (void)viewDidLoad
{

  [super viewDidLoad];

  NSString *filePath = [[NSBundle mainBundle] pathForResource:@"snow" ofType:@"gif"];
  NSData *gif = [NSData dataWithContentsOfFile:filePath];

  UIWebView *webViewBG = [[UIWebView alloc] initWithFrame:self.view.frame];
  [webViewBG loadData:gif MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];
  webViewBG.userInteractionEnabled = NO;
  [self.view addSubview:webViewBG];

  UIView *filter = [[UIView alloc] initWithFrame:self.view.frame];
  //filter.backgroundColor = [UIColor redColor];
  filter.alpha = 0.5;
  [self.view addSubview:filter];
4

1 回答 1

1

您可以设置视图背景清除颜色并且对于动画图像,您可以使用 UIImageView。希望这会正常工作。见链接:: -点击这里获取代码 Link2::-点击这里获取代码

于 2015-01-14T06:22:58.493 回答