I have set up VNDocumentCameraViewController
for scanning documents automatically. I want to hide the cancel and capture buttons from the screen. Is it possible to hide these buttons?
Code:-
import UIKit
import Vision
import VisionKit
import AVFoundation
class DocumentScannerViewController: UIViewController, VNDocumentCameraViewControllerDelegate {
var previewLayer: AVCaptureVideoPreviewLayer?
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let scannerViewController = VNDocumentCameraViewController()
scannerViewController.delegate = self
present(scannerViewController, animated: true)
previewLayer = AVCaptureVideoPreviewLayer(session: AVCaptureSession())
previewLayer?.videoGravity = .resizeAspectFill
previewLayer?.frame = view.bounds
previewLayer?.cornerRadius = 10
previewLayer?.opacity = 0.75
previewLayer?.borderColor = UIColor.red.cgColor
previewLayer?.borderWidth = 5.0
view.layer.addSublayer(previewLayer!)
}
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
for pageNumber in 0..<scan.pageCount {
let image = scan.imageOfPage(at: pageNumber)
if let imageData = image.jpegData(compressionQuality: 1.0) {
print(imageData)
}
if let cgImage = image.cgImage {
print("cgImage", cgImage)
}
}
controller.dismiss(animated: true)
}
func documentCameraViewControllerDidCancel(_ controller: VNDocumentCameraViewController) {
controller.dismiss(animated: true)
}
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFailWithError error: Error) {
print(error)
controller.dismiss(animated: true)
}
}
Please refer to the attached screenshot for clarification.
My question is, how can I hide these buttons? I've tried the above code, but haven't achieved any results yet.