iOS 7(子层)AVPlayer 全屏动画,需要在上面(覆盖)UINavigationBar

标签 ios fullscreen avplayer avplayerlayer

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

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

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

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

目前:我将 UINavigationBar hide 和 status bar hide 设置为存档,但这不是目标并且旋转没有问题

非常感谢!!!

附注单击信息图标切换到全屏 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];

}

最佳答案

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

您的另一个选择是当有人按下全屏按钮时隐藏导航栏。

更新:

也许选项 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;!

关于iOS 7(子层)AVPlayer 全屏动画,需要在上面(覆盖)UINavigationBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30624726/

相关文章:

iphone - 在 IOS 中使用 native 控件进行本地化

ios - 多个UITableViewCells在点击时会做不同的事情

javascript - React 网络应用程序在加载时启动并请求全屏 - 已编辑

ios - 当应用程序处于后台时,是否无法更改 AVPlayer 或 AVQueuePlayer 中的播放器项目

swift - AVQueuePlayer 视频在 Swift 中不起作用

ios - 如何确定 iOS 连接类型(Edge、3G、4G、Wifi)?

iphone - iOS:自定义图像 UIBarButtonItem 不响应触摸

python - 在 PyGTK 中使用 F11 切换全屏的简单方法

html - 全屏背景不适用于移动设备

uiimage - 从附加到AVPlayer的CALayer获取UIImage(从视频播放中提取帧)