你好,我想在我的应用程序中打开相机
我只想在该部分的中间打开一个摄像头,这样用户只能在矩形部分中拍摄
我正在使用的代码就是这个
import UIKit
import AVFoundation
class TakeProductPhotoController: UIViewController {
let captureSession = AVCaptureSession()
var previewLayer : AVCaptureVideoPreviewLayer?
// If we find a device we'll store it here for later use
var captureDevice : AVCaptureDevice?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
captureSession.sessionPreset = AVCaptureSessionPresetHigh
let devices = AVCaptureDevice.devices()
// Loop through all the capture devices on this phone
for device in devices {
// Make sure this …
Run Code Online (Sandbox Code Playgroud)