Created
May 5, 2016 02:41
-
-
Save traviskirton/909fd0f3aea8b427fc17b0024dc7bf3f to your computer and use it in GitHub Desktop.
Simple demo of ScreenRecorder... Creates animated points when the user quickly flicks the screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import C4 | |
| import UIKit | |
| class WorkSpace: CanvasController { | |
| var screenRecorder: ScreenRecorder? | |
| override func setup() { | |
| self.screenRecorder = ScreenRecorder() | |
| self.screenRecorder?.recordingEndedAction = { | |
| self.screenRecorder?.showPreviewInController(self) | |
| } | |
| addPan() | |
| addStartRecording() | |
| } | |
| func addStartRecording() { | |
| canvas.addLongPressGestureRecognizer { (locations, center, state) in | |
| if state == .Began && !self.screenRecorder!.recording { | |
| ShapeLayer.disableActions = true | |
| let r = Rectangle(frame: self.canvas.bounds) | |
| self.canvas.add(r) | |
| let a = ViewAnimation(duration: 0.25) { | |
| r.opacity = 0.0 | |
| } | |
| a.addCompletionObserver { | |
| r.removeFromSuperview() | |
| self.screenRecorder?.start(5.0) | |
| } | |
| a.animate() | |
| } | |
| } | |
| } | |
| func addPan() { | |
| canvas.addPanGestureRecognizer { (locations, center, translation, velocity, state) in | |
| if state == .Began { | |
| for location in locations { | |
| ShapeLayer.disableActions = true | |
| let c = Circle(center: location, radius: 1) | |
| self.canvas.add(c) | |
| ShapeLayer.disableActions = false | |
| let a = ViewAnimation(duration: 0.5) { | |
| let newC = Circle(center: location, radius: 50.0) | |
| c.path = newC.path | |
| c.adjustToFitPath() | |
| c.center = location | |
| c.opacity = 0.0 | |
| } | |
| a.addCompletionObserver() { | |
| c.removeFromSuperview() | |
| } | |
| a.animate() | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment