Uikit 正在从AVPlayerViewController.customoverlayViewController中删除UIVisualEffect
我正在实现avplayervewcontroller.customOverlayViewController,我想知道是否有办法删除UIVisualEffect并在演示文稿上应用清晰的背景。我附加了一个屏幕截图与视图HirechayUikit 正在从AVPlayerViewController.customoverlayViewController中删除UIVisualEffect,uikit,avplayerviewcontroller,Uikit,Avplayerviewcontroller,我正在实现avplayervewcontroller.customOverlayViewController,我想知道是否有办法删除UIVisualEffect并在演示文稿上应用清晰的背景。我附加了一个屏幕截图与视图Hirechay 根据视图层次结构,ChannelViewController是AVxCustomOverlayHostViewController的一部分,其类型为AVxHostView的视图包括UIVisualEffectView。因此: override func viewWi
根据视图层次结构,ChannelViewController是AVxCustomOverlayHostViewController的一部分,其类型为AVxHostView的视图包括UIVisualEffectView。因此:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Remove UIVisualEffectView
if let parent = parent {
parent.view.subviews.filter({ $0 is UIVisualEffectView }).forEach({ $0.alpha = 0 })
}
}
如果你愿意,你也可以把它移除。@Reimond Hill的答案很好。谢谢你。 您可能需要删除底部间距并固定高度,以构建完全相同的覆盖视图,该视图在序列图像板或xib文件上填充屏幕的全宽和全高。在这种情况下,我们必须修改约束 这是我在控制台日志面板上看到的
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002dd1d10 AVxHostView:0x7fc3163678f0.height == 1140 (active)>
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002d800f0 UIView:0x7fc312c8ff10.bottom == AVxHostView:0x7fc3163678f0.bottom - 60 (active)>
这个答案很好!。我们如何删除底部边距?很高兴它有帮助!关于底部,我不确定。可能尝试调试“parent.view”(AVxHostView)框架或约束…您是否可以尝试一下并分享您的经验?谢谢我找到了解决办法!请核对我的答案。
if let parent = parent {
parent.view.subviews.filter({ $0 is UIVisualEffectView }).forEach({ $0.alpha = 0 })
for constraint in parent.view.constraints {
if let second = constraint.secondItem as? UIView,
second == parent.view,
constraint.secondAnchor == parent.view.bottomAnchor {
constraint.constant = 0
}
}
for constraint in parent.view.constraints {
if let first = constraint.firstItem as? UIView,
first == parent.view,
constraint.firstAttribute == .height {
constraint.constant = UIScreen.main.bounds.size.height
}
}
}