Commit 8174c729 by Daniel Dahan

added to CaptureView Example

parent 0dfcc81b
......@@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt.png",
"filename" : "ic_photo_camera_white_48pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt@2x.png",
"filename" : "ic_photo_camera_white_48pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt@3x.png",
"filename" : "ic_photo_camera_white_48pt@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_videocam_white_48pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_videocam_white_48pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_videocam_white_48pt@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -22,6 +22,9 @@ import AVFoundation
class ViewController: UIViewController, CaptureSessionDelegate {
private lazy var captureView: CaptureView = CaptureView()
private lazy var cameraButton: FlatButton = FlatButton()
private lazy var captureButton: FabButton = FabButton()
private lazy var videoButton: FlatButton = FlatButton()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -68,16 +71,26 @@ class ViewController: UIViewController, CaptureSessionDelegate {
btn3.setImage(img3, forState: .Normal)
btn3.setImage(img3, forState: .Highlighted)
let img4: UIImage? = UIImage(named: "ic_photo_camera_white_36pt")
let captureButton: FabButton = FabButton()
captureButton.backgroundColor = MaterialColor.black.colorWithAlphaComponent(0.3)
let img4: UIImage? = UIImage(named: "ic_photo_camera_white_48pt")
cameraButton.pulseColor = nil
cameraButton.setImage(img4, forState: .Normal)
cameraButton.setImage(img4, forState: .Highlighted)
cameraButton.addTarget(self, action: "handleCameraButton:", forControlEvents: .TouchUpInside)
captureButton.pulseColor = MaterialColor.white
captureButton.pulseFill = true
captureButton.backgroundColor = MaterialColor.blue.darken1.colorWithAlphaComponent(0.3)
captureButton.borderWidth = .Border2
captureButton.borderColor = MaterialColor.grey.darken1
captureButton.shadowDepth = .None
captureButton.setImage(img4, forState: .Normal)
captureButton.setImage(img4, forState: .Highlighted)
captureButton.addTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside)
let img5: UIImage? = UIImage(named: "ic_videocam_white_48pt")
videoButton.pulseColor = nil
videoButton.setImage(img5, forState: .Normal)
videoButton.setImage(img5, forState: .Highlighted)
videoButton.addTarget(self, action: "handleVideoButton:", forControlEvents: .TouchUpInside)
captureView.captureSession.delegate = self
captureView.captureButton = captureButton
captureView.flashButton = btn1
......@@ -87,11 +100,21 @@ class ViewController: UIViewController, CaptureSessionDelegate {
captureView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: captureView)
view.addSubview(cameraButton)
cameraButton.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomLeft(view, child: cameraButton, bottom: 24, left: 24)
// MaterialLayout.size(view, child: cameraButton, width: 48, height: 48)
view.addSubview(captureButton)
captureButton.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomRight(view, child: captureButton, bottom: 24, right: (view.bounds.width - 72) / 2)
MaterialLayout.size(view, child: captureButton, width: 72, height: 72)
view.addSubview(videoButton)
videoButton.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomRight(view, child: videoButton, bottom: 24, right: 24)
// MaterialLayout.size(view, child: videoButton, width: 48, height: 48)
view.addSubview(navigationBarView)
navigationBarView.leftButtons = [btn3]
navigationBarView.rightButtons = [btn1, btn2]
......@@ -118,7 +141,7 @@ class ViewController: UIViewController, CaptureSessionDelegate {
/**
:name: handleFlashButton
*/
internal func handleFlashButton(sender: AnyObject) {
internal func handleFlashButton(button: UIButton) {
var img: UIImage?
switch captureView.captureSession.flashMode {
......@@ -141,6 +164,20 @@ class ViewController: UIViewController, CaptureSessionDelegate {
}
/**
:name: handleCameraButton
*/
func handleCameraButton(button: UIButton) {
captureButton.backgroundColor = MaterialColor.blue.darken1.colorWithAlphaComponent(0.3)
}
/**
:name: handleVideoButton
*/
func handleVideoButton(button: UIButton) {
captureButton.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3)
}
/**
:name: captureSessionFailedWithError
*/
func captureSessionFailedWithError(capture: CaptureSession, error: NSError) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment