我正在尝试为闪屏显示多个图像。我正在显示3个图像作为闪屏。第一个是闪屏的默认图像,而不是使用Ui-imageview,我在我的Imageview上显示第二个和第三个图像。
我想在更改闪屏时淡出图像。我尝试了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
}
发布于 2013-03-08 22:24:56
你可以创建两个要在start中显示的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
调用该函数,还可以添加所需的时间间隔。
https://stackoverflow.com/questions/15295149
复制相似问题