我发现 repay kit 有助于用音频记录屏幕,但问题是它将整个屏幕的活动记录为带音频的视频,但我想记录主视图上存在的特定视图的活动。所以我的问题是 Replay Kit 是否允许我通过录音来记录特定的视图活动。如果是,请帮助我实现同样的目标。提前致谢。任何帮助将不胜感激。
以下代码帮助我记录整个屏幕的活动:
func startRecording() {
let recorder = RPScreenRecorder.shared()
if #available(iOS 9.0, *) {
recorder.startRecording(withMicrophoneEnabled: true) { [unowned self] (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Stop", style: .plain, target: self, action: #selector(PreviewVC.stopRecording))
}
}
} else {
// Fallback on earlier versions
}
}
func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopRecording { [unowned self] (preview, error) in
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(PreviewVC.startRecording))
if let unwrappedPreview = preview {
unwrappedPreview.previewControllerDelegate = self
self.present(unwrappedPreview, animated: true, completion: nil)
}
}
}