Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LongPress minDuration = 0
//
// WorkSpace.swift
// LongPressExample
//
// Created by travis on 2016-03-14.
// Copyright © 2016 C4. All rights reserved.
//
import UIKit
class WorkSpace: CanvasController {
override func setup() {
longpressCanvas()
longpressObject()
}
func longpressCanvas() {
let lp = canvas.addLongPressGestureRecognizer { locations, center, state in
switch state {
case .Began:
self.canvas.backgroundColor = C4Purple
case .Ended:
self.canvas.backgroundColor = C4Grey
default:
break
}
}
lp.minimumPressDuration = 0.0
}
func longpressObject() {
let obj = Circle(center: canvas.center, radius: 100)
let lp = obj.addLongPressGestureRecognizer { locations, center, state in
switch state {
case .Began:
obj.fillColor = C4Pink
case .Ended:
obj.fillColor = C4Blue
default:
break
}
}
lp.minimumPressDuration = 0.0
canvas.add(obj)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment