makeCluster()如何在全屏模式下在AVPLayerViewController的中心添加活动指示器?
答案 0 :(得分:1)
您可以通过在主键窗口上添加自定义视图,在AVPLayerViewController的中心添加自定义指标视图。
UIApplication.shared.keyWindow?.addSubview(your custom indicator view)
您可以将自定义指标视图的中心设置如下。
activity.center = CGPoint.init(x: UIScreen.main.bounds.size.width/2.0, y: UIScreen.main.bounds.height/2.0)
答案 1 :(得分:0)
当用户按播放按钮
时添加此代码if(playerViewController.view.subviews.count != 0)
{
UIView *AVTouchIgnoringView = playerViewController.view.subviews[0].subviews.lastObject;
activityIndicatorBuffer.center = playerViewController.view.center;
[AVTouchIgnoringView addSubview:activityIndicatorView];
[AVTouchIgnoringView bringSubviewToFront:activityIndicatorView];
}
并且不要忘记添加以下方法
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[playerViewController addObserver:self forKeyPath:@"videoBounds" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
}
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[playerViewController removeObserver:self forKeyPath:@"videoBounds"];
}
-(void)observeValueForKeyPath:(NSString )keyPath ofObject:(id)object change:(NSDictionary )change context:(void *)context
{
if ([keyPath isEqualToString:@"videoBounds"])
{
float height = playerViewController.contentOverlayView.bounds.size.height;
float width = playerViewController.contentOverlayView.bounds.size.width;
if (height == SCREEN_HEIGHT && width == SCREEN_WIDTH)
{
activityIndicatorBuffer.center = playerViewController.contentOverlayView.center;
}
else
{
activityIndicatorBuffer.center = playerViewController.view.center;
}
}
}
并且不要忘记在缓冲时开始制作动画。点击此处this link for check AVPlayer is buffering