mirror of
https://github.com/samsonjs/SwiftyCam.git
synced 2026-04-02 10:25:51 +00:00
Updated demo buttons
This commit is contained in:
parent
e2c84707f4
commit
9f9a8a0e17
2 changed files with 8 additions and 25 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue