Giter Site home page Giter Site logo

recordbutton's Introduction

RecordButton

CI Status Version License Platform

A Record Button in Swift. Inspired by SDRecordButton It shows you the recording process when recording. It's great for a video recorder app with a fixed/maximum length like snapchat, vine, instragram.

Screenshot

Requirements

iOS 8 and higher

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

RecordButton is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "RecordButton"

Add this line add the top of the file you want to use this module in import RecordButton

Usage

Add a simple RecordButton

Add this to viewDidLoad

let recordButton = RecordButton(frame: CGRect(x: 0,y: 0,width: 70,height: 70))
view.addSubview(recordButton) 

Update progress

it's the easiest to just check out the example project for this.

To update progress the RecordButton must be an instance of the class. You should also add a progressTimer and a progress variable, like this:

class ViewController: UIViewController {

	var recordButton : RecordButton!
	var progressTimer : Timer!
	var progress : CGFloat = 0
	
	// rest of viewController 
	

The recordButton needs a target for start and stopping the progress timer. Add this code after initialization of the recordButton (usualy in viewDidLoad())

recordButton.addTarget(self, action: #selector(self.record), for: .touchDown)
recordButton.addTarget(self, action: #selector(self.stop), for: UIControl.Event.touchUpInside)

Finally add these functions to your ViewController

    @objc func record() {
        self.progressTimer = Timer.scheduledTimer(timeInterval: 0.05, target: self, selector: #selector(ViewController.updateProgress), userInfo: nil, repeats: true)
    }
    
    @objc func updateProgress() {
        
        let maxDuration = CGFloat(5) // Max duration of the recordButton
        
        progress = progress + (CGFloat(0.05) / maxDuration)
        recordButton.setProgress(progress)
        
        if progress >= 1 {
            progressTimer.invalidate()
        }
        
    }
    
    @objc func stop() {
        self.progressTimer.invalidate()
    }
    

Support/Issues

If you have any questions, please don't hesitate to create an issue.

To Do

  • Add Carthage Support
  • Add a delegation pattern

Author

samuelbeek - iOS Developer, Consultant and Occasional Designer

Acknowledgements

This button is heavely inspired by SDRecordButton, which is made by Sebyddd

License

RecordButton is available under the MIT license. See the LICENSE file for more info.

recordbutton's People

Contributors

aelavell avatar digitallysavvy avatar felipericieri avatar gannonprudhomme avatar samuelbeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

recordbutton's Issues

Prevent animation from reoccurring after every progress

Hey, I was wondering how to prevent the button from animating after every time you record. Would love it if the button did the animation and stayed in it's recording state and every subsequent press and release it did not keep doing the animation. Thanks!

Can't build

Not exactly sure what's going on here since it seems there was a merged PR to update this to Swift 4 but I am getting errors building as you can see below

Im using CocoaPods and doing pod install ....pretty standard stuff. Any idea what's going on? Thanks!

screen shot 2019-01-25 at 2 46 30 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.