在相机预览视图上添加按钮 [BESwiftCamera lib]
Adding button over camera preview view [BESwiftCamera lib]
在我的 swift 应用程序中,我正在使用此库构建自定义摄像机:https://github.com/bwearley/BESwiftCamera
在我的视图控制器中:
var camera:BESwiftCamera!
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.attachCamera()
}
func attachCamera() {
do {
try self.camera.start()
} catch BESwiftCameraErrorCode.CameraPermission {
self.showCameraPermissionAlert()
} catch BESwiftCameraErrorCode.MicrophonePermission {
self.showMicrophonePermissionAlert()
} catch {
self.showUnknownErrorAlert()
}
}
override func viewDidLoad() {
super.viewDidLoad()
let screenRect = UIScreen.mainScreen().bounds
// Configure Camera
self.camera = BESwiftCamera(withQuality: AVCaptureSessionPresetHigh, position: .Rear, videoEnabled: true)
self.camera.attachToViewController(self, withFrame: CGRectMake(0,0,screenRect.size.width,screenRect.size.height))
...
}
这很好用。但是,问题是它加载了我在情节提要中针对此特定视图的元素(按钮)。 如何在相机预览视图上加载故事板元素?
更新库中的行
https://github.com/bwearley/BESwiftCamera/blob/master/BESwiftCamera/BESwiftCamera.swift#L139
vc.view.addSubview(self.view)
到
vc.view.insertSubview(self.view, atIndex: 0)
在我的 swift 应用程序中,我正在使用此库构建自定义摄像机:https://github.com/bwearley/BESwiftCamera
在我的视图控制器中:
var camera:BESwiftCamera!
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.attachCamera()
}
func attachCamera() {
do {
try self.camera.start()
} catch BESwiftCameraErrorCode.CameraPermission {
self.showCameraPermissionAlert()
} catch BESwiftCameraErrorCode.MicrophonePermission {
self.showMicrophonePermissionAlert()
} catch {
self.showUnknownErrorAlert()
}
}
override func viewDidLoad() {
super.viewDidLoad()
let screenRect = UIScreen.mainScreen().bounds
// Configure Camera
self.camera = BESwiftCamera(withQuality: AVCaptureSessionPresetHigh, position: .Rear, videoEnabled: true)
self.camera.attachToViewController(self, withFrame: CGRectMake(0,0,screenRect.size.width,screenRect.size.height))
...
}
这很好用。但是,问题是它加载了我在情节提要中针对此特定视图的元素(按钮)。 如何在相机预览视图上加载故事板元素?
更新库中的行
https://github.com/bwearley/BESwiftCamera/blob/master/BESwiftCamera/BESwiftCamera.swift#L139
vc.view.addSubview(self.view)
到
vc.view.insertSubview(self.view, atIndex: 0)