我有一个启动画面,我想拥有它,以便用户第一次打开应用程序时,它们会显示更多信息的启动画面,否则只会显示常规启动画面。我只是通过在应用程序第一次加载时将它们带到页面顶部再次绘制闪屏图像来实现这一点,然后淡出额外信息,它看起来非常好,它完全按照我想要的方式工作,除了当启动画面卸载并且我正在绘制的图像加载时,转换之间会有轻微的闪烁,并且它非常明显。我想知道是否有办法避免这种闪烁并使转换无缝,这样你甚至不能告诉你正在查看不同的页面。
这是我目前的代码,myDict可以检查用户是否已经在任何时候打开了应用程序:
-(void) viewDidAppear:(BOOL)animated {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"acctInfo.txt"];
NSMutableDictionary *myDict = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
if(myDict == nil){
int yPos = 370;
NSString *imagePath = @"Default-568h@2x.png";
if([UIScreen mainScreen].bounds.size.height == 480.0f){
yPos = 300;
imagePath = @"Default@2x.png";
}
UIImageView *splash = [self addImage:imagePath toSubview:self.view atX:0 atY:0 atWidth:[UIScreen mainScreen].bounds.size.width atHeight:[UIScreen mainScreen].bounds.size.height];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"splash_text.png"]];
[imageView setFrame:CGRectMake(63,yPos,193,56)];
[imageView setAlpha:0.0f];
[self.view addSubview:imageView];
[UIView animateWithDuration:1.0
delay:1.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{ imageView.alpha = 1; }
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
delay:1.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{ imageView.alpha = 0;
splash.alpha = 0;}
completion:^(BOOL finished){}
];
}
];
}
}
有没有消除闪烁?非常感谢任何帮助,谢谢!