iOS 7 (sublayer) AVPlayer Fullscreen animation 需要在上面 (cover) UINavigationBar
iOS 7 (sublayer) AVPlayer Fullscreen animate and need to above (cover) UINavigationBar
我正在尝试放弃 MPMoviePlayerController 并切换到 AVPlayer 但在 'AVPlayer(Layer) Full Screen animation' 上遇到问题。
项目源代码:http://www.kevin-and-idea.com/avplayer.zip
目标:目前,AVPlayer(Layer) 是ViewController 上元素的一部分。播放需要可以在'Small'和全屏之间切换,全屏时需要在(覆盖)雕像栏和导航栏上方。此外,播放器需要旋转取决于设备方向
问题:不知道如何'take out' AVPlayerLayer 和'Cover' 整个屏幕包括状态栏和导航栏。
当前:我将 UINavigationBar hide 和 status bar hide 设置为存档,但这不是目标,旋转没有问题
非常感谢!!!
p.s。单击信息图标切换到全屏
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];
}
您有两个选择(也许更多):
您创建的视图在视图层次结构中比您的导航控制器视图更高,因此您可以只放置 'above' 的内容。这可能是视觉上最吸引人的一个,我相信大多数专业应用程序都使用它。
您的另一个选择是在有人按下全屏按钮时隐藏导航栏。
更新:
也许 'better' 选项 1 的方式:
我看了上一篇。我的项目,也许你想使用这个:
创建一个新的 window 来包含您的 avplayer。
子类化 UIView 并实现一个 'show' 方法,如下所示:
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;
!
我正在尝试放弃 MPMoviePlayerController 并切换到 AVPlayer 但在 'AVPlayer(Layer) Full Screen animation' 上遇到问题。
项目源代码:http://www.kevin-and-idea.com/avplayer.zip
目标:目前,AVPlayer(Layer) 是ViewController 上元素的一部分。播放需要可以在'Small'和全屏之间切换,全屏时需要在(覆盖)雕像栏和导航栏上方。此外,播放器需要旋转取决于设备方向
问题:不知道如何'take out' AVPlayerLayer 和'Cover' 整个屏幕包括状态栏和导航栏。
当前:我将 UINavigationBar hide 和 status bar hide 设置为存档,但这不是目标,旋转没有问题
非常感谢!!!
p.s。单击信息图标切换到全屏 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];
}
您有两个选择(也许更多): 您创建的视图在视图层次结构中比您的导航控制器视图更高,因此您可以只放置 'above' 的内容。这可能是视觉上最吸引人的一个,我相信大多数专业应用程序都使用它。
您的另一个选择是在有人按下全屏按钮时隐藏导航栏。
更新:
也许 'better' 选项 1 的方式:
我看了上一篇。我的项目,也许你想使用这个:
创建一个新的 window 来包含您的 avplayer。
子类化 UIView 并实现一个 'show' 方法,如下所示:
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;
!