【问题标题】:Customise the color of buttons in the RPPreviewViewController (ReplayKit)自定义 RPPreviewViewController (ReplayKit) 中按钮的颜色
【发布时间】:2021-06-24 17:08:12
【问题描述】:

我已经用 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)
        }
    }
``

【问题讨论】:

    标签: swift button colors replaykit


    【解决方案1】:

    在展示/推送视图控制器时尝试以下代码

    UINavigationBar.appearance().barTintColor = Colors.redColor()
    UINavigationBar.appearance().tintColor = UIColor.white
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)] 
    

    请注意:在关闭/弹出视图控制器时不要忘记重置所有这些值,因为所有这些值都适用于整个应用程序中的所有导航控制器。

    【讨论】:

    • 不幸的是,这不起作用。我试过这个。我也试过这个 previewVC.navigationController!.navigationBar.barTintColor = .systemRed。 navigationController 为 nil。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 2019-12-09
    • 2015-10-18
    • 1970-01-01
    • 1970-01-01
    • 2020-08-13
    相关资源
    最近更新 更多