CameraKit / camerakit-ios

Library for iOS Camera API. Massively increase performance and ease of use within your next iOS Project.
Apache License 2.0
686 stars 82 forks source link

Camera not filling screen #19

Open bstillitano opened 5 years ago

bstillitano commented 5 years ago

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

  1. Setup a basic preview view which fills the ViewController it is contained in
  2. Launch the app
  3. 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()
        }
    }

}

File

chezhe commented 4 years ago

What's .snp?

chezhe commented 4 years ago

I use it with SwiftUI, it's size not as the frame I set.

bstillitano commented 4 years ago

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

croossin commented 4 years ago

Any updates on this?

bstillitano commented 4 years ago

Any updates on this?

They’ve abandoned this library.

kenny-numerade commented 4 years ago

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!