2013-03-08 70 views
0

我想动画多个图像的启动screen.i显示3图像作为启动屏幕第一个是启动屏幕的默认图像比使用Ui-imageview我显示第二和第三我的Imageview。Fadout飞溅屏幕上的多个图像在IOS

我想在更改启动画面时淡出图像。我试过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 
} 
+0

检查此链接http://stackoverflow.com/questions/13540300/fade-out-image-animation-in-iphone – Rushabh 2013-03-08 13:39:33

+0

@Rushabh他已经提出NStimer技巧是不是有用的在他的情况。请再次阅读该问题。 – 2013-03-08 13:41:12

+0

@Rushabh在NStimmer的情况下,它不显示默认图像,它直接跳转到第二张图像,并比主屏幕..第三闪屏和主屏幕不显示在NStimmer ..我要添加NStimer代码在主要问题可以你请提出任何解决方案 – 2013-03-08 13:49:37

回答

1

U可以创建要显示在启动两种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该功能,并可以添加所需的时间间隔。

+0

你能帮我吗我已经编写代码,但他们有些困惑..我要编辑主要问题请尽可能帮我 – 2013-03-08 15:36:36

+0

@SwapAndroid - 你需要写代码图像视图在代码中隐藏:'[[backgroundImageView layer] addAnimation:animation3 forKey:@“SwitchToView”];'这是'backgroundImageView2',你已经写了'backgroundImageView'。您需要将动画添加到您需要动画的组件层。你的情况是'backgroundImageView2',而不是'backgroundImageView'。更改代码。动画将会发生。上面我写的代码也是一样的。 – NiKKi 2013-03-11 07:42:28

+0

我试着按照你所说的改变几行代码,然后我不显示我的splashscreen-2它直接显示启动屏幕-1和启动屏幕-3之后..你可以在这里粘贴你的代码,所以我可以让我的理念更清晰请。 – 2013-03-11 09:14:20