Skip to content

Commit

Permalink
Merge pull request #11 from gannonprudhomme/patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
samuelbeek authored Aug 22, 2018
2 parents 1c3d0af + fdaacba commit 05fd1a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ The `recordButton` needs a target for start and stopping the progress timer. Add

```swift

recordButton.addTarget(self, action: "record", forControlEvents: .TouchDown)
recordButton.addTarget(self, action: "stop", forControlEvents: UIControlEvents.TouchUpInside)
recordButton.addTarget(self, action: #selector(ViewController.record), for: .touchDown)
recordButton.addTarget(self, action: #selector(ViewController.stop), for: UIControlEvents.touchUpInside)

```

Finally add these functions to your ViewController

```swift

func record() {
self.progressTimer = NSTimer.scheduledTimerWithTimeInterval(0.05, target: self, selector: "updateProgress", userInfo: nil, repeats: true)
@objc func record() {
self.progressTimer = Timer.scheduledTimer(timeInterval: 0.05, target: self, selector: #selector(ViewController.updateProgress), userInfo: nil, repeats: true)
}

func updateProgress() {
@objc func updateProgress() {

let maxDuration = CGFloat(5) // max duration of the recordButton
let maxDuration = CGFloat(5) // Max duration of the recordButton

progress = progress + (CGFloat(0.05) / maxDuration)
recordButton.setProgress(progress)
Expand All @@ -94,7 +94,7 @@ Finally add these functions to your ViewController

}

func stop() {
@objc func stop() {
self.progressTimer.invalidate()
}

Expand Down

0 comments on commit 05fd1a2

Please sign in to comment.