我正在尝试将图像视图添加到我的应用程序窗口,该窗口由splitviewcontroller组成。我这样做的原因是我可以像闪屏一样淡出它。该应用程序适用于iPad,仅适用于横向模式。启动图像与启动图像相同,因此它是两者之间的无缝过渡,然后我可以手动淡出启动画面。但是,我在向启动图像的方向相同的方向上添加启动到窗口的子视图时遇到问题,因此从启动图像到启动画面的过渡是无缝的,无法被注意到。以下是我到目前为止的情况:
- (void)viewDidLoad
{
[super viewDidLoad];
UIWindow *window = [[UIApplication sharedApplication] delegate].window;
UIImageView *splash = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
splash.image = [UIImage imageNamed:@"Default-Landscape~ipad.png"];
[splash rotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
[window addSubview:splash];
}
@interface UIView (Orientation)
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation;
@end
@implementation UIView (Orientation)
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
CGFloat angle = 0.0;
switch (orientation) {
case UIInterfaceOrientationPortraitUpsideDown:
angle = M_PI;
break;
case UIInterfaceOrientationLandscapeLeft:
angle = - M_PI / 2.0f;
break;
case UIInterfaceOrientationLandscapeRight:
angle = M_PI / 2.0f;
break;
default: // As portrait
angle = 0.0;
break;
}
self.transform = CGAffineTransformMakeRotation(angle);
}
@end