camerakit-ios
camerakit-ios copied to clipboard
Camera not filling screen
Is this a bug report?
Yes.
Have you read the Contributing Guidelines?
Yes.
Environment
CameraKit Version: 1.2.0
iOS Device: iPhone X
iOS Version: 12.1.3
Steps to Reproduce
- Setup a basic preview view which fills the ViewController it is contained in
- Launch the app
- On devices with a notch (or taller devices in general) there will be white borders above and below the actual preview view.
Expected Behavior
Based on popular apps and most other libraries, the expectation from myself (which may not be correct) is that the preview would fill its parent view instead of fit. At a mininmum I'd expect the ability to actually set this behaviour by choice.
Actual Behavior
There is no ability to specify fill/fit mode. This is the code and the outcome.
import UIKit
import CameraKit_iOS
import SnapKit
class CameraViewController: UIViewController {
//UI Elements
var previewView: CKFPreviewView = CKFPreviewView()
var cameraSession: CKFPhotoSession = CKFPhotoSession()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//Setup Preview
previewView.session = cameraSession
self.view.addSubview(previewView)
//Update Preview Constraints
previewView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
}
}
What's .snp
?
I use it with SwiftUI, it's size not as the frame I set.
What's
.snp
?
SnapKit. Apologies for using a third party library in an issue. Have verified that even using CGRect as the frame the issue persists.
https://github.com/SnapKit/SnapKit
Any updates on this?
Any updates on this?
They’ve abandoned this library.
I had the same issue of the camera view not filling the entire screen, but I solved it by setting the CKFPreviewView.video.previewLayer.videoGravity = .resizeAspectFill
in viewDidLayoutSubviews
Hope that helps anyone reading this!