-3

Is it possible to recreate the behavior of the flashlight button from iphone X lockscreen? I am of course interested only in using public APIs supported by Apple.

1 Answers1

0

Try this !

  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

        guard let touchPosition = touches.first else {  return  }

        // Check if 3D touch is available
        if .available == self.traitCollection.forceTouchCapability{

            // Perform action for tap with force
            if touch.force > 1.0{
                // Touch pressure gretaer than normal tap

                // TODO:
            }
        }
    }

You can also check this method: touch.maximumPossibleForce

Force touch value 1.0 is the default as per the documentation. average force

Apple Documentation

Prateek Pande
  • 495
  • 3
  • 12