diff --git a/DemoSwiftyCam/DemoSwiftyCam/SwiftyRecordButton.swift b/DemoSwiftyCam/DemoSwiftyCam/SwiftyRecordButton.swift index 4f48c4b..5e7643d 100644 --- a/DemoSwiftyCam/DemoSwiftyCam/SwiftyRecordButton.swift +++ b/DemoSwiftyCam/DemoSwiftyCam/SwiftyRecordButton.swift @@ -8,7 +8,7 @@ import UIKit -class SwiftyRecordButton: SwiftyCamButton, UIGestureRecognizerDelegate { +class SwiftyRecordButton: SwiftyCamButton { private var circleBorder: CALayer! private var innerCircle: UIView! @@ -34,21 +34,7 @@ class SwiftyRecordButton: SwiftyCamButton, UIGestureRecognizerDelegate { circleBorder.position = CGPoint(x: self.bounds.midX, y: self.bounds.midY) circleBorder.cornerRadius = self.frame.size.width / 2 layer.insertSublayer(circleBorder, at: 0) - - let longPress = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(gesture:))) - longPress.delegate = self - self.addGestureRecognizer(longPress) - } - - func handleLongPress(gesture: UILongPressGestureRecognizer){ - switch gesture.state { - case .began: - growButton() - case .ended: - shrinkButton() - default: - break - } + } public func growButton() { @@ -95,8 +81,4 @@ class SwiftyRecordButton: SwiftyCamButton, UIGestureRecognizerDelegate { circleBorder.add(scale, forKey: "grow") } - - func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { - return true - } } diff --git a/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift b/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift index 580d359..f496662 100644 --- a/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift +++ b/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift @@ -44,6 +44,7 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate { func SwiftyCamDidBeginRecordingVideo() { print("Did Begin Recording") + captureButton.growButton() UIView.animate(withDuration: 0.25, animations: { self.flashButton.alpha = 0.0 self.flipCameraButton.alpha = 0.0 @@ -52,6 +53,7 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate { func SwiftyCamDidFinishRecordingVideo() { print("Did finish Recording") + captureButton.shrinkButton() UIView.animate(withDuration: 0.25, animations: { self.flashButton.alpha = 1.0 self.flipCameraButton.alpha = 1.0 @@ -106,20 +108,19 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate { private func addButtons() { captureButton = SwiftyRecordButton(frame: CGRect(x: view.frame.midX - 37.5, y: view.frame.height - 100.0, width: 75.0, height: 75.0)) self.view.addSubview(captureButton) - //self.view.bringSubview(toFront: captureButton) captureButton.delegate = self - flipCameraButton = UIButton(frame: CGRect(x: view.frame.width / 4 - 15.0, y: view.frame.height - 74.0, width: 30.0, height: 23.0)) + flipCameraButton = UIButton(frame: CGRect(x: (((view.frame.width / 2 - 37.5) / 2) - 15.0), y: view.frame.height - 74.0, width: 30.0, height: 23.0)) flipCameraButton.setImage(#imageLiteral(resourceName: "flipCamera"), for: UIControlState()) flipCameraButton.addTarget(self, action: #selector(cameraSwitchAction(_:)), for: .touchUpInside) self.view.addSubview(flipCameraButton) - //self.view.bringSubview(toFront: flipCameraButton) - flashButton = UIButton(frame: CGRect(x: view.frame.width * 3 / 4 - 9.0, y: view.frame.height - 77.5, width: 18.0, height: 30.0)) + let test = CGFloat((view.frame.width - (view.frame.width / 2 + 37.5)) + ((view.frame.width / 2) - 37.5) - 9.0) + + flashButton = UIButton(frame: CGRect(x: test, y: view.frame.height - 77.5, width: 18.0, height: 30.0)) flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControlState()) flashButton.addTarget(self, action: #selector(toggleFlashAction(_:)), for: .touchUpInside) self.view.addSubview(flashButton) - // self.view.bringSubview(toFront: flashButton) } }