From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Using haptics

Using haptics

- If you have an iPhone seven or eight, you might think the home button is a fiscal button, if you completely shut off the phone, you find it's a solid circle. What makes that click is a haptic. You can easily use haptics in your application to make buttons click or warn the user. I suggest downloading exercise file, haptics only work on a live phone. Will not work on the simulator. Take a look at the starter file. I have a simple button. Right click on the button, and you'll see that I have a touch down, and a touch up event. Okay, go ahead and click out of there, and go to the ViewController.swift code, and give yourself some space, we're only going to be in here for now, and you'll see the click me down and click me up functions. Now there's three types of haptics. The impact generator can be used for a collision of objects on the screen, whereas I use it for a touch of a finger to a button for a click. At the very top of the code above the actions, I'm going to add an impact…

Contents