I would like use camera in my iPhone inside of View. I don't want use typical full screen camera view, but my own.
For example I would like have a square 200x200 at the middle of the screen and there have a camera preview. Below this square I would like have a button to take a picture. How to do it? I'm swift beginer.
An another code block. how you can do manual focus with iPhone.
You'll want to use the
AVFoundation
Framework to allow you to make your ownAVCaptureSession
inside of a view that you create in your storyboard. Here is a nice tutorial showing you how to find the camera and create a capture session:http://jamesonquave.com/blog/taking-control-of-the-iphone-camera-in-ios-8-with-swift-part-1/
This tutorial uses the whole view as the capture view, so that is how big the camera will be if you model it after his code. To make a 200x200 square in the middle of the screen, you have to draw one out on your view controller in your storyboard, link it to a variable in your swift file where all the code is going, and then change the part at the bottom that says,
to
your200by200View.layer.frame
Hopefully this can help. If not, I can try to help some more or someone can correct me.
Good luck!
An example of how you can add a
cameraOverlayView
to create a 200x200 square viewing window at the center of the screen: