0

我正在尝试为启动屏幕制作多个图像。我正在显示 3 个图像作为启动屏幕第一个是启动屏幕的默认图像,而不是使用 Ui-imageview 我在我的 Imageview 上显示第 2 个和第 3 个。

我想在更改启动画面时淡出图像。我尝试了 NSTimmer 解决方案,但它向我显示了直接的第三张图像和缅因屏幕,而不是在我尝试了这个解决方案之后,但它一次又一次地显示了我的第二张和第三张图像 2 次。任何帮助表示赞赏

已编辑/- Nikki 建议我一些解决方案,但我很困惑我在哪个地方取消隐藏我的第二个图像视图?这是我的代码

backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
backgroundImageView.image=[UIImage imageNamed:@"SPLASHSCREEN-2.png"];
backgroundImageView2 = [[UIImageView alloc] initWithFrame:self.view.bounds];
backgroundImageView2.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
backgroundImageView2.image=[UIImage imageNamed:@"SPLASHSCREEN-3.png"];
[self.view addSubview:backgroundImageView];
[self.view addSubview:backgroundImageView2];
[backgroundImageView2 setHidden:YES];
[self performSelector:@selector(performTransition) withObject:nil afterDelay:1.0];

-(void)performTransition
   {
CATransition *animation3 = [CATransition animation];
[animation3 setDuration:3.0f];
[animation3 setType:kCATransitionReveal];
[animation3 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[backgroundImageView layer] addAnimation:animation3 forKey:@"SwitchToView"];
[backgroundImageView setHidden:YES];
[backgroundImageView2 setHidden:NO];//No animation happen while changing the image view
}
4

1 回答 1

1

您可以创建两个ImageView要在开始时显示并首先将它们设置为隐藏。只需编写代码以进行动画处理:

-(void)performTransition
{  
  CATransition *animation3 =  [CATransition animation];
  [animation3  setDuration:3.0f];
  [animation3  setType:kCATransitionReveal];
  [animation3  setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
  [[backgroundImageView2  layer] addAnimation:animation3 forKey:@"SwitchToView"];
  [backgroundImageView  setHidden:YES];
  [backgroundImageView2  setHidden:NO];//No animation happen while changing the image view
} 

并设置 ImageView 将在取消隐藏时进行动画处理。可以通过更改 的值来更改动画类型[animation3 setType:kCATransitionReveal];。记得导入:#import<QuartzCore/QuartzCore.h>

为了用动画隐藏ImageView上一个并用动画显示下一个ImageView,您可以在函数内编写代码,并可以使用该函数调用该函数,performSelector并且可以添加所需的时间间隔。

于 2013-03-08T14:24:55.653 回答