启动iOS应用程序时,屏幕从Default.png跳转到界面。对于当前的项目,我想从该Default.png淡入到应用程序的界面中。有什么好方法可以做到这一点吗?
发布于 2012-07-04 02:47:29
我采用了一些rooster117和runmad的答案,这就是我想出来的。
将UIImageView添加到第一个UIViewController的属性中:
@interface DDViewController : UIViewController {
...
UIImageView *coverImageView;
}
...
@property (nonatomic, retain) UIImageView *coverImageView;然后,对于iPad应用程序的“主屏幕”,我调用以下代码:
- (void)viewDidLoad
{
[super viewDidLoad];
...
coverImageView = [[UIImageView alloc] init];
}
-(void)viewWillAppear:(BOOL)animated {
UIImage *defaultImage;
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
NSLog(@"Landscape!");
defaultImage = [UIImage imageNamed:@"Default-Landscape.png"];
} else {
NSLog(@"Portrait!");
defaultImage = [UIImage imageNamed:@"Default-Portrait.png"];
}
coverImageView = [[UIImageView alloc] initWithImage:defaultImage];
[self.view addSubview:coverImageView];
}
-(void)viewDidAppear:(BOOL)animated {
//Remove the coverview with an animation
[UIView animateWithDuration:1.0f animations:^(void) {
[self.coverImageView setAlpha:0.0];
} completion:^(BOOL finished){
[coverImageView removeFromSuperview];
}];
}发布于 2012-07-04 01:50:28
是的,这并不难做到。我通过使用默认图像创建一个图像视图,并对其进行动画处理。如下所示(放入第一个视图控制器的viewDidLoad中):
_coverImage = [UIImage imageNamed:@"Default.png"];
}
[self.view addSubview:_coverImage];
[UIView beginAnimations:@"FadeOutCover" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeAndDeleteCover)];
[_coverImage setAlpha:0.0f];
[UIView commitAnimations];然后实现removeAndDeleteCover并执行以下操作:
[_coverImage removeFromSuperview];希望这会有帮助,如果你需要它作为一个通用的应用程序在iPad上工作,你将不得不检查这种情况并添加正确的默认图像。
发布于 2012-07-04 02:17:09
有人在cocoacontrols.com上做了一个控件
这是它的链接:http://cocoacontrols.com/platforms/ios/controls/launchimagetransition
https://stackoverflow.com/questions/11316325
复制相似问题