Hi,
I am trying to record the screen and microfone inside my application using ReplayKit. It records everything without problems and at the end I present the preview through this code:
recorder.stopRecording { [weak self] (preview, error) in
guard preview != nil else {
print("Preview not available")
return
}
preview?.previewControllerDelegate = self
self?.present(preview!, animated: true, completion: nil)
}
The problem is here, the RPPreviewViewController obtained in the callback does not respect the safe area for iPhone X.
The buttons are too close to the edges and the title is hidden below the notch.
I also tryed to embed the RPPreviewViewController into another UIViewController (a simple wrapper), but it seems like the height is fixed, so if I lower the top part the bottom one goes out of the screen.
Any clue of what I am doing wrong? Any help is appreciated.
Thanks!
I could change the position of the bottom bar with this code.
let safeArea = self.view.safeAreaInsets
let safeAreaHeight = self.view.frame.height - (safeArea.top + safeArea.bottom)
let safeAreaWidth = self.view.frame.width - (safeArea.left + safeArea.right)
let scaleX = safeAreaWidth / self.view.frame.width
let scaleY = safeAreaHeight / self.view.frame.height
let scale = min(scaleX, scaleY)
previewViewController.view.transform = CGAffineTransform(scaleX: scale, y: scale)
self.present(previewViewController, animated: true) {
previewViewController.view.frame.origin.x += safeArea.left
previewViewController.view.frame.origin.y += safeArea.top
}