Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ForceTouchButton.swift
- //
- // Created by Robert Dougan on 09/10/15.
- // Copyright © 2015 Robert Dougan. All rights reserved.
- //
- import UIKit
- extension UIControlEvents {
- static var ForceTouchDown = UIControlEvents(rawValue: 512)
- }
- class ForceTouchButton: UIButton {
- override func continueTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool {
- if traitCollection.forceTouchCapability == .Available {
- if (touch.force == touch.maximumPossibleForce) {
- self.sendActionsForControlEvents(.ForceTouchDown)
- return false
- }
- }
- return super.continueTrackingWithTouch(touch, withEvent: event)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement