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.
Asked
Active
Viewed 62 times
1 Answers
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

Prateek Pande
- 495
- 3
- 12