0

我正在尝试将图像视图添加到由 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
4

0 回答 0