Created
February 28, 2017 06:58
-
-
Save m4rr/9ee53d1d27d6c2c0227bb718d711963a to your computer and use it in GitHub Desktop.
UISelectionFeedbackGenerator iOS 9 compatible
This file contains 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 UIKit | |
@available(iOS 10.0, *) | |
private var _generator: UISelectionFeedbackGenerator? | |
class SelectionFeedbackGenerator { | |
init() { | |
if #available(iOS 10, *) { | |
_generator = UISelectionFeedbackGenerator() | |
_generator?.prepare() | |
} | |
} | |
func selectionChanged() { | |
if #available(iOS 10, *) { | |
_generator?.selectionChanged() | |
_generator?.prepare() | |
} | |
} | |
deinit { | |
if #available(iOS 10, *) { | |
_generator = nil | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment