如何在AVPlayerViewController顶部添加UITextView

问题描述

我有一个播放音轨的应用。以前,当我使用MPMoviePlayerViewController时,我能够将UITextView放在播放器顶部以显示歌词。自从切换到AVPlayerViewController以来,我看到可以在视图顶部添加文本的唯一方法是使用contentOverlayView-但是文本窗口是静态的,不会像在MPMoviePlayerViewController上那样滚动。

发现实现此目的的另一种方法是将UITextView作为子视图添加到窗口,但随后它出现在AVPlayer下方,而我一直无法将其移到播放器顶部。我已经尝试过使用BringSubviewToFront,但这不起作用。

这是我添加TextView的方式:

   textViewAZ = [[UITextView alloc] init];
    
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    if (orientation == UIInterfaceOrientationPortrait)
    {
        textViewAZ.frame = CGRectMake(40,140,self.view.frame.size.width-80,self.view.frame.size.height-150);
    }
    else
    {
        textViewAZ.frame = CGRectMake(150,self.view.frame.size.height-100);
    }
textViewAZ.text = playingLyrics;
textViewAZ.backgroundColor = [UIColor blackColor];
textViewAZ.textColor = [UIColor whiteColor];
textViewAZ.scrollEnabled = YES;
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
[currentWindow addSubview:textViewAZ];
[currentWindow bringSubviewToFront:textViewAZ];

有人知道在AVPlayerViewController顶部放置可滚动文本视图的方法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)