是否有任何库可以记录特定的活动UIView
(我遇到了这个库[ASScreenRecorder
-master] 但当我尝试在 swift 中使用它或任何其他方式记录时,它显示出许多错误UIView
哪个正在显示一些动画,例如飘落的雪花和图像的幻灯片放映?我希望将它们录制为单个视频并将它们保存到图库中。我已经四处寻找一些解决方案,但我仍然无法记录视图。请帮忙。提前致谢。
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。 (看本教程 https://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos)。在您的应用程序中考虑一种记录整个屏幕的方法 - 也许将 UIView 扩展到屏幕边界。
尝试查看其中一些 Github 文件:
File1 https://github.com/wess/Glimpse
File2 https://github.com/adam-roth/screen-cap-view
File3 https://github.com/andydrizen/UIViewRecorder
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)