Skip to content

Instantly share code, notes, and snippets.

@codePrincess
Last active August 3, 2017 14:37
Show Gist options
  • Save codePrincess/a05de638adf98be14ea582d9e4aed1d6 to your computer and use it in GitHub Desktop.
Save codePrincess/a05de638adf98be14ea582d9e4aed1d6 to your computer and use it in GitHub Desktop.
timer for tracking the users doodling coordinates
public func setup () {
resetDoodleRect()
lastTouchTimestamp = 0
if #available(iOS 10.0, *) {
trackTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true, block: {
timer in
let now = Date().timeIntervalSince1970
if Int(self.lastTouchTimestamp!) > 0 && now - self.lastTouchTimestamp! > 1 {
self.drawDoodlingRect(context: self.context)
}
})
} else {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment