Latest1.0.2
Homepagehttps://github.com/samuelbeek/RecordButton
LicenseMIT
Platformsios 8.0, requires ARC
FrameworksUIKit
Authors

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: CGRectMake(0,0,70,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 : NSTimer!
    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: "record", forControlEvents: .TouchDown)
recordButton.addTarget(self, action: "stop", forControlEvents: UIControlEvents.TouchUpInside)

Finally add these functions to your ViewController


    func record() {
        self.progressTimer = NSTimer.scheduledTimerWithTimeInterval(0.05, target: self, selector: "updateProgress", userInfo: nil, repeats: true)
    }

    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()
        }

    }

    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.

Latest podspec

{
    "name": "RecordButton",
    "version": "1.0.2",
    "summary": "A Record Button in Swift.",
    "description": "A Modulair Record Button in Swift. 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.",
    "homepage": "https://github.com/samuelbeek/RecordButton",
    "screenshots": "http://i.imgur.com/WTO3KLC.png",
    "license": "MIT",
    "authors": {
        "samuelbeek": "[email protected]"
    },
    "source": {
        "git": "https://github.com/samuelbeek/RecordButton.git",
        "tag": "1.0.2"
    },
    "social_media_url": "https://twitter.com/samuelbeek",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This