首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在IOS的闪屏上淡出多个映像

在IOS的闪屏上淡出多个映像
EN

Stack Overflow用户
提问于 2013-03-08 21:33:21
回答 1查看 245关注 0票数 0

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

我想在更改闪屏时淡出图像。我尝试了NSTimmer解决方案,但它显示我的直接第三个图像和缅因州的屏幕后,我尝试这个解决方案,但它显示我的第二个和第三个图像一个接一个地2次。任何帮助我们都将不胜感激

编辑/- Nikki建议我一些解决方案,但我有困惑的地方,我解开了我的第二个图像视图?以下是我的代码

代码语言:javascript
运行
复制
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
}
EN

回答 1

Stack Overflow用户

发布于 2013-03-08 22:24:56

你可以创建两个要在start中显示的ImageView,并首先将它们设置为隐藏。只需编写代码即可实现动画:

代码语言:javascript
运行
复制
-(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调用该函数,还可以添加所需的时间间隔。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15295149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档