Skip to content

Instantly share code, notes, and snippets.

View buddax2's full-sized avatar

Oleksandr Yakubchyk buddax2

View GitHub Profile
@buddax2
buddax2 / VanishingView.m
Last active March 4, 2016 14:24 — forked from NSExceptional/VanishingView.m
A UIView subclass that fades away more the harder you press on it, and eventually disappears if you press hard enough. iOS 9 only, of course.
extension UIView {
override public func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
self.alpha = 1 - touch.force / touch.maximumPossibleForce
if touch.force == touch.maximumPossibleForce {
self.removeFromSuperview()
}
}
}