是否有任何库可以记录特定UIView
的事件(我遇到了这个库[ASScreenRecorder
-master],但当我尝试使用它时它显示了许多错误以 swift )或任何其他方式记录正在显示一些动画(如落雪和图像幻灯片放映)的 UIView ?我希望将它们录制为单个视频并将它们保存到图库中。我四处寻找一些解决方案,但我仍然无法记录 View 。请帮忙。提前致谢。
func start() {
let sharedRecorder = RPScreenRecorder.shared()
// Do nothing if screen recording is not available
guard sharedRecorder.isAvailable else { return }
// Stop previous recording if necessary
if sharedRecorder.isRecording {
stopScreenRecording()
}
print("Starting screen recording")
// Register as the recorder's delegate to handle errors.
sharedRecorder.delegate = self
// Start recording
if #available(iOS 10.0, *) {
#if os(iOS)
sharedRecorder.isMicrophoneEnabled = true
//sharedRecorder.isCameraEnabled = true // fixme
#endif
sharedRecorder.startRecording { [unowned self] error in
if let error = error as? NSError, error.code != RPRecordingErrorCode.userDeclined.rawValue {
print(error.localizedDescription)
// Show alert
return
}
}
} else {
// Fallback on earlier versions
sharedRecorder.startRecording(withMicrophoneEnabled: true) { error in
if let error = error as? NSError, error.code != RPRecordingErrorCode.userDeclined.rawValue {
print(error.localizedDescription)
// Show alert
return
}
}
}
}
最佳答案
不幸的是,您当前无法记录特定的 UIView。您可以使用 ReplayKit 录制整个屏幕,但我知道这不是您想要的。
其他想法:
记录“整个屏幕”,但尝试裁剪到 UIView。 (参见this tutorial)。在您的应用程序中考虑一种记录整个屏幕的方法 - 也许将 UIView 扩展到屏幕边界。
尝试查看其中一些 Github 文件:
关于ios - 在iOS swift中查看录音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45583997/