1

我正在尝试放弃 MPMoviePlayerController 并切换到 AVPlayer,但在“AVPlayer(Layer) 全屏动画”上遇到问题。

项目源代码:http ://www.kevin-and-idea.com/avplayer.zip

目标:目前,AVPlayer(Layer) 是 ViewController 上元素的一部分。播放需要能够在“小”和全屏之间切换,并且当它全屏时,它需要在(覆盖)雕像栏和导航栏的上方。此外,播放器需要可旋转取决于设备方向

问题:不知道如何“取出”AVPlayerLayer 并“覆盖”整个屏幕,包括雕像栏和导航栏。

目前:我将 UINavigationBar hide 和 status bar hide 设置为存档,但这不是目标并且可以毫无问题地旋转

太感谢了!!!

ps 点击信息图标切换到全屏 https://c1.staticflickr.com/1/388/18237765479_7d3c292449_z.jpg

代码

- (IBAction)goFullScreen:(id)sender {

[UIView animateWithDuration:0.25
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     if (topSpaceConstraints.priority == 999) {
                         videoContainerSizeRatioConstraints.priority = 250;
                         [[UIApplication sharedApplication] setStatusBarHidden:YES];
                         [self.navigationController setNavigationBarHidden:YES];
                         topSpaceConstraints.priority = 250;
                     } else {
                         videoContainerSizeRatioConstraints.priority = 999;
                         [[UIApplication sharedApplication] setStatusBarHidden:NO];
                         [self.navigationController setNavigationBarHidden:NO];
                         topSpaceConstraints.priority = 999;
                     }
                     [self.view layoutIfNeeded];

                 }
                 completion:nil];

}
4

1 回答 1

1

您有两个选择(可能更多):您创建的视图在视图层次结构中比导航控制器视图更高,因此您可以只放置“上方”的内容。可能这将是最具视觉吸引力的一个,我相信大多数专业应用程序都使用它。

您拥有的另一个选项就是在有人按下全屏按钮时隐藏导航栏。

更新:

对于选项 1,也许是一种“更好”的方式:

我看了上一篇 我的项目,也许你想用这个:

创建一个新窗口来包含您的 avplayer。

子类 UIView 并实现这样的“显示”方法:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.alpha = 0;
self.window.windowLevel = UIWindowLevelAlert;
self.window.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.0f];

[self.window addSubview:self];

[self.window addSubview:self];
[self.window makeKeyAndVisible];

[UIView animateKeyframesWithDuration:0.3 delay:0 options:UIViewKeyframeAnimationOptionBeginFromCurrentState animations:^{

        [UIView addKeyframeWithRelativeStartTime:0. relativeDuration:0.7 animations:^{
            // PROBABLY MORE ANIMATION HERE...
            self.alpha = 1;
        }];

        [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:1 animations:^{
            self.window.backgroundColor = [UIColor colorWithWhite:0.0f alpha:self.targetDimmDensity];

        }];
    } completion:^(BOOL finished) {

    }];

这是我创造self.window的一个新的!@property (nonatomic, strong) UIWindow *window;

于 2015-06-03T16:28:23.777 回答