iOS Haptic Feedback for iPhone 6s, 7 (or newer)
On iPhone 7 (or newer).
let selectionFeedbackGenerator = UISelectionFeedbackGenerator() selectionFeedbackGenerator.prepare() selectionFeedbackGenerator.selectionChanged()
On iPhone 6s (via work-around)
import AudioToolbox AudioServicesPlaySystemSound(1519) AudioServicesPlaySystemSound(1520) AudioServicesPlaySystemSound(1521) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
Taptic-Engine 微震動
if (@available(iOS 10.0, *)) { UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleHeavy]; [generator prepare]; [generator impactOccurred]; }
如何使用UIFeedbackGenerator 讓應用支持iOS 10 的觸覺反饋
Last updated 4 years ago