【问题标题】:iOS 7 (sublayer) AVPlayer Fullscreen animate and need to above (cover) UINavigationBariOS 7(子层)AVPlayer Fullscreen animate 需要上面(覆盖)UINavigationBar
【发布时间】:2015-06-03 15:40:13
【问题描述】:

我正在尝试放弃 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];

}

【问题讨论】:

    标签: ios fullscreen avplayer avplayerlayer


    【解决方案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;

    【讨论】:

    • 谢谢尼尔斯!同意你的观点,似乎只有两种选择。
    • 哇!这是一个很好的聪明的解决方案!请向 Nils 致敬
    猜你喜欢
    • 2014-05-27
    • 2015-04-22
    • 2020-08-02
    • 2013-09-28
    • 1970-01-01
    • 2014-01-07
    • 1970-01-01
    • 1970-01-01
    • 2013-09-20
    相关资源
    最近更新 更多