jRecordView
一个简单的带有录音功能的录音视图,支持长按录音和滑动取消
演示
安装
jRecordView 通过 CocoaPods 提供。要安装它,只需要将以下行添加到您的 Podfile 中
pod 'iRecordView'
使用方法
使用代码或 Storyboard 将 RecordButton
和 RecordView
视图添加到 ViewController 中
let recordButton = RecordButton()
recordButton.translatesAutoresizingMaskIntoConstraints = false
let recordView = RecordView()
recordView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(recordButton)
view.addSubview(recordView)
recordButton.widthAnchor.constraint(equalToConstant: 35).isActive = true
recordButton.heightAnchor.constraint(equalToConstant: 35).isActive = true
recordButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -8).isActive = true
recordButton.bottomAnchor.constraint(equalTo: view.safeBottomAnchor, constant: -16).isActive = true
recordView.trailingAnchor.constraint(equalTo: recordButton.leadingAnchor, constant: -20).isActive = true
recordView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10).isActive = true
recordView.bottomAnchor.constraint(equalTo: recordButton.bottomAnchor).isActive = true
现在将您的 recordView
添加到 recordButton
//IMPORTANT
recordButton.recordView = recordView
现在您可以通过代理来观察状态
recordView.delegate = self
这将提供 4 个功能
func onStart() {
//start recording
print("onStart")
}
func onCancel() {
//when users swipes to delete the Record
print("onCancel")
}
func onFinished(duration: CGFloat) {
//user finished recording
print("onFinished \(duration)")
}
//optional
func onAnimationEnd() {
//when Trash Animation is Finished
print("onAnimationEnd")
}
定制
//Cancel Record when Slide To Cancel view gets before duration time + offset
recordView.offset = 20
//enable/disable Record Sounds
recordView.isSoundEnabled = true
recordView.durationTimerColor = .red
recordView.smallMicImage = myImage
recordView.slideToCancelText = "Test"
recordView.slideToCancelTextColor = .red
recordView.slideToCancelArrowImage = myImage
//to Handle Clicks by RecordButton you have to disable touch Gesture by using
recordButton.listenForRecord = false
作者
AbdulAlim Rajjoub
致谢/评分
RATTLESNAKE-VIPER 为 GLMoveToTrashAnimation
寻找安卓版本?
尝试 RecordView
许可证
iRecordView 适用于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。