我用 RPScreenRecorder 录制了一个视频序列。一切正常。
现在我想自定义预览控制器的UI。 如何更改取消和保存按钮的颜色? 是的,总的来说我知道如何改变 UIBarButtonItem 的颜色:
let cancelBtn = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(self.dismissView))
cancelBtn.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .normal)
但是我在预览(RPPreviewViewController)中找不到按钮的引用。
func stopRecorder() {
recorder.stopRecording { [unowned self] (preview, error) in
guard let previewVC = preview else {
return
}
previewVC.previewControllerDelegate = self
previewVC.modalPresentationStyle = .fullScreen
self.present(previewVC, animated: true, completion: nil)
}
}
``
在呈现/推送视图控制器时尝试下面的代码
UINavigationBar.appearance().barTintColor = Colors.redColor()
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)]
请注意:不要忘记在关闭/弹出视图控制器时重置所有这些值,因为所有这些值都适用于整个应用程序中的所有导航控制器。
如果您在 SwiftUI 中使用 RPPreviewViewController,我可以使用 accentColor 更改预览控制器导航栏中按钮的颜色。
if isShowPreviewVideo {
replayKitPreview
.transition(.move(edge: .bottom))
.accentColor(Color(hex: 0x0096FF))
.edgesIgnoringSafeArea(.all)
}