Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //
  2. // ForceTouchButton.swift
  3. //
  4. // Created by Robert Dougan on 09/10/15.
  5. // Copyright © 2015 Robert Dougan. All rights reserved.
  6. //
  7.  
  8. import UIKit
  9.  
  10. extension UIControlEvents {
  11. static var ForceTouchDown = UIControlEvents(rawValue: 512)
  12. }
  13.  
  14. class ForceTouchButton: UIButton {
  15.  
  16. override func continueTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool {
  17. if traitCollection.forceTouchCapability == .Available {
  18. if (touch.force == touch.maximumPossibleForce) {
  19. self.sendActionsForControlEvents(.ForceTouchDown)
  20.  
  21. return false
  22. }
  23. }
  24.  
  25. return super.continueTrackingWithTouch(touch, withEvent: event)
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement