Skip to content

Instantly share code, notes, and snippets.

View SAllen0400's full-sized avatar

Sean Allen SAllen0400

View GitHub Profile
@SAllen0400
SAllen0400 / longpressGestureLength.swift
Created February 16, 2017 04:47
Get length of Long Press Gesture
// Swift 3
// If you'd like to use the gestureDuration outside of the scope of the button press, create some variables.
var gestureStartTime: TimeInterval!
var gestureDuration: TimeInterval!
// IBAction for UILongPressGestureRecognizer
@IBAction func recordButtonHeld(_ sender: UILongPressGestureRecognizer) {
switch sender.state {
@SAllen0400
SAllen0400 / sortByProperty.swift
Last active March 8, 2017 22:59
Sorting an array by an object property
// Swift 3
// Simple object example
class Phone {
let name: String
let serialNumber: Int
init(name: String, serialNumber: Int) {
self.name = name
@SAllen0400
SAllen0400 / buttonAnimationExtension.swift
Created March 15, 2017 00:04
Core Animation on UIButton Example
// Swift 3
extension UIButton {
func pulsate() {
let pulse = CASpringAnimation(keyPath: "transform.scale")
pulse.duration = 0.6
pulse.fromValue = 0.95
pulse.toValue = 1.0
@SAllen0400
SAllen0400 / sortArray.swift
Created April 3, 2017 05:11
Swift Snippet #2
class Player {
let name: String
let highScore: Int
init(name: String, highScore: Int) {
self.name = name
self.highScore = highScore
}
}