Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hyun99999/uifeedbackgeneratortutorial-ios

๐Ÿ‘†UIFeedbackGeneratorTutorial ํ–…ํ‹ฑ ๋Œ€์ž‘์ „
https://github.com/hyun99999/uifeedbackgeneratortutorial-ios

Last synced: 27 days ago
JSON representation

๐Ÿ‘†UIFeedbackGeneratorTutorial ํ–…ํ‹ฑ ๋Œ€์ž‘์ „

Awesome Lists containing this project

README

        

# UIFeedbackGeneratorTutorial-iOS
๐Ÿ‘†UIFeedbackGeneratorTutorial ํ–…ํ‹ฑ ๋Œ€์ž‘์ „

### ๋‚ด์šฉ

- shake motion ์„ ์ธ์‹ํ•ด์„œ ํ™”๋ฉด์ „ํ™˜ ์‹œ ์ง„๋™ ์ถ”๊ฐ€

# ์‹œ์ž‘ ์ „

apple developer ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ์—์„œ๋Š” ์•„์ดํฐ์—์„œ ์‚ฌ์šฉํ• ๋•Œ ๋Š๋‚„ ์ˆ˜ ์žˆ๋Š” "๋šœ๋‘‘" ํ˜น์€ "๋š" ํ•˜๋Š” ์ด๋Ÿฌํ•œ ์ด‰๊ฐ ๊ฒฝํ—˜์„ haptic ์œผ๋กœ ๋ช…์‹œํ•˜๊ณ  ์žˆ๋‹ค.

์ง„๋™๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ ํ–…ํ‹ฑ ๊ด€๋ จํ•ด์„œ ๊ณต๋ถ€๋ฅผ ํ•˜๋‹ค๊ฐ€ ํ–…ํ‹ฑ ํŒจํ„ด์„ ์ ‘ํ•˜๊ณ  ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ์ง„๋™์€ ์—†๊ตฌ๋‚˜ ๋ผ๊ณ  ๋Š๊ผˆ๋‹ค. ๊ทธ๋ž˜๋„ ๊ณต๋ถ€ํ•œ๊ฒŒ ์•„์‰ฌ์›Œ์„œ ๋‚จ๊ธด๋‹ค.

### Haptics ์™€ Vibrate

- ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ ์‹œ(ex.์นด์นด์˜คํŽ˜์ด) โ†’ ํ–…ํ‹ฑ
- ์ค‘์š”ํ•œ ํŒ์—… ๋“ฑ์žฅ ์‹œ(ex.์นด์นด์˜คํ†ก ํ์•Œ์ฝ”๋“œ) โ†’ ๋ฐ”์ด๋ธŒ๋ ˆ์ดํŠธ

## ๐Ÿ™Œ [HIG - Haptics](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/haptics/)

- Human Interface Guidelines ์˜ ํ•„์š”ํ•œ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•ด๋ณด์ž. ๋ฌธ์„œ์—์„œ ์—ฌ๋Ÿฌ ํŒจํ„ด์˜ ์ง„๋™ ๋ฏธ๋””์–ด๊นŒ์ง€ ์ œ๊ณตํ•˜๋‹ˆ ๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋งํฌ๋ฅผ ํ™•์ธํ•ด๋ณด์ž.

### Haptics

ํ–…ํ‹ฑ์€ ์‚ฌ๋žŒ๋“ค์˜ ์ด‰๊ฐ์— ๊ด€์—ฌํ•˜์—ฌ ํ™”๋ฉด ์ธํ„ฐํŽ˜์ด์Šค์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๊ฒฝํ—˜์„ ํ–ฅ์ƒ์‹œํ‚จ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์‹œ์Šคํ…œ์€ ์‹œ๊ฐ ๋ฐ ์ฒญ๊ฐ ํ”ผ๋“œ๋ฐฑ๊ณผ ๋”๋ถˆ์–ด ํ–…ํ‹ฑ์„ ์žฌ์ƒํ•˜์—ฌ Apple Pay ๊ฑฐ๋ž˜์˜ ํ™•์ธ์„ ๊ฐ•์กฐ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ picker ๋ฅผ ์Šคํฌ๋กคํ•˜๊ฑฐ๋‚˜ switch ๋ฅผ ํ† ๊ธ€ํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ํ„ฐ์น˜ ์ œ์Šค์ฒ˜ ๋ฐ ์ƒํ˜ธ์ž‘์šฉ์„ ๊ฐ•์กฐํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ฐœ๋ฐœ์ž ์ง€์นจ์€ [Animation and Haptics](https://developer.apple.com/documentation/uikit/animation_and_haptics) ๋ฅผ ์ฐธ์กฐํ•ด๋ผ.

์ง€์›๋˜๋Š” iPhone ๋ชจ๋ธ์—์„œ๋Š” ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์œผ๋กœ ์•ฑ์— ํ–…ํ‹ฑ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.

- Use standard UI elements โ€” likeย [switches](https://developer.apple.com/documentation/uikit/uiswitch),ย [sliders](https://developer.apple.com/documentation/uikit/uislider), andย [pickers](https://developer.apple.com/documentation/uikit/uipickerview)ย โ€” that play Apple-designed system haptics by default.
- When it makes sense, use a feedback generator to play one of several predefined haptic patterns in the categories ofย [notification](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/haptics/#notification),ย [impact](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/haptics/#impact), andย [selection](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/haptics/#selection)ย (for developer guidance, seeย [UIFeedbackGenerator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator)).
- In situations where you want more control, compose and play your own haptic patterns. For guidance, seeย [Creating Custom Haptic Patterns](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/haptics/#creating-custom-haptic-patterns).

์‹œ์Šคํ…œ ์ œ๊ณต ์ปจํŠธ๋กค ๋ฐ ํ–…ํ‹ฑ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ iOS ๋Š” ๊ฐ•๋„์™€ ํ”ผ๋“œ๋ฐฑ์˜ ๋™์ž‘์„ ๊ด€๋ฆฌํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์Šค์œ„์น˜๋Š” ๋ฏธ๋ฌ˜ํ•œ tap ์„ ์ž๋™์œผ๋กœ ์žฌ์ƒํ•˜๊ณ  "success" notification ์— ๋Œ€ํ•œ feedback generator ๋Š” ์•„๋ž˜์˜ ํŒจํ„ด์„ ์žฌ์ƒํ•œ๋‹ค. ์‚ฌ๋žŒ๋“ค์€ ์‹œ์Šคํ…œ ์ •์˜ ํ–…ํƒ์„ ์ธ์‹ํ•˜๋ฏ€๋กœ ๋ฌธ์„œํ™”๋œ ์˜๋ฏธ์— ๋”ฐ๋ผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค.

(์œ„์˜ HIG ๋ฌธ์„œ์—์„œ๋Š” ์‹ค์ œ๋กœ ํ–…ํ‹ฑ์„ ์ฒดํ—˜ํ•ด๋ณผ ์ˆ˜ ์žˆ๋‹ค! ๊ผญ ๋“ค์–ด๊ฐ€์„œ ํ™•์ธํ•ด๋ณด๊ธธ ๋ฐ”๋ž€๋‹ค.)

### Notification

Notification haptics ๋Š” ์ž‘์—… ๋˜๋Š” ์ž‘์—…์˜ ๊ฒฐ๊ณผ์— ๋Œ€ํ•œ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•œ๋‹ค.

- ๋งํฌ์—์„œ ์—ฌ๋Ÿฌ ํŒจํ„ด์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

### Impact

Impact haptics ๋Š” ์‹œ๊ฐ์  ๊ฒฝํ—˜์„ ๋ณด์™„ํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌผ๋ฆฌ์  ๋ฉ”ํƒ€ํฌ๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์‚ฌ๋žŒ๋“ค์€ view ๊ฐ€ ์ œ์ž๋ฆฌ์— ๊ณ ์ •๋  ๋•Œ ํƒญ์„ ๋Š๋ผ๊ฑฐ๋‚˜ ๋‘ ๊ฐœ์˜ ๋ฌด๊ฑฐ์šด ๋ฌผ์ฒด๊ฐ€ ์ถฉ๋Œํ•  ๋•Œ ์ฟต ์†Œ๋ฆฌ๋ฅผ ๋Š๋‚„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

- ๋งํฌ์—์„œ ์—ฌ๋Ÿฌ ํŒจํ„ด์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

### Selection

Selection haptics ๋Š” UI ์š”์†Œ์˜ ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋Š” ๋™์•ˆ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•œ๋‹ค.

- ๋งํฌ์—์„œ ์—ฌ๋Ÿฌ ํŒจํ„ด์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์‹œ์Šคํ…œ์—์„œ ์ œ๊ณตํ•˜๋Š” ํ–…ํ‹ฑ์„ ์‚ฌ์šฉํ•˜๋“  ์ž์ฒด์ ์œผ๋กœ ๋งŒ๋“ค๋“  ์‚ฌ๋žŒ๋“ค์„ ๋ชฉํ‘œ์—์„œ ๋ฐฉํ•ดํ•˜์ง€ ์•Š์œผ๋ฉด์„œ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ํ’๋ถ€ํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฐฉ์‹์œผ๋กœ ํ–…ํ‹ฑ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค.

---

์ดํ›„์˜ HIG ๋ฌธ์„œ๋Š” **haptics ๋กœ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋””์ž์ธํ•˜๋Š” ๋‚ด์šฉ**๊ณผ **Custom Haptic Patterns ๋ฅผ ๋งŒ๋“œ๋Š” ๋‚ด์šฉ**์„ ์ œ๊ณตํ•œ๋‹ค.

์ด์ œ ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ๋ฅผ ์‚ดํŽด๋ณด์ž!

## ๐Ÿ™Œ [Apple Developer - Animation and Haptics](https://developer.apple.com/documentation/uikit/animation_and_haptics)

### ๐Ÿ“Œ Haptick Feedback

Provide haptic feedback in response to specific types of events.

- [classย UIFeedbackGenerator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator)

: The abstract superclass for all feedback generators.

- [classย UIImpactFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiimpactfeedbackgenerator)

: A concreteย [UIFeedbackGenerator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator)ย subclass that creates haptics to simulate physical impacts.

- [classย UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbackgenerator)

: A concreteย [UIFeedbackGenerator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator)ย subclass that creates haptics to communicate successes, failures, and warnings.

- [classย UISelectionFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiselectionfeedbackgenerator)

: A concreteย [UIFeedbackGenerator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator)ย subclass that creates haptics to indicate a change in selection.

## ๐Ÿ‘ ์›๋ฆฌ

To use a feedback generator, the following are required:

1. [Instantiating the Generator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator#2555404)
- feedback ์„ ์ƒ์„ฑํ•˜๋ ค๋ฉด ๋จผ์ € `UIFeedbackGenerator` ํด๋ž˜์Šค์˜ ๊ตฌ์ฒด์ ์ธ ํ•˜์œ„ํด๋ž˜์Šค(`UIImpactFeedbackGenerator`, `UISelectionFeedbackGenerator`, or `UINotificationFeedbackGenerator`) ์ค‘ ํ•˜๋‚˜๋ฅผ ์ธ์Šคํ„ด์Šคํ™” ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.
2. [Preparing the Generator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator#2555405)ย (optional)
- generator ๋ฅผ preparing ํ•˜๋ฉด์„œ feedback ์„ ํŠธ๋ฆฌ๊ฑฐํ• ๋•Œ ๋Œ€๊ธฐ์‹œ๊ฐ„์„ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค. ์ด๊ฒƒ์€ ์†Œ๋ฆฌ ๋˜๋Š” ์‹œ๊ฐ์  ์‹ ํ˜ธ์™€ ๋งค์น˜ํ• ๋•Œ ํŠนํžˆ ์ค‘์š”ํ•˜๋‹ค.
- generator ์˜ [prepare()](https://developer.apple.com/documentation/uikit/uifeedbackgenerator/2369818-prepare) ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด Taptic Engine ์ด ์ค€๋น„์ƒํƒœ๊ฐ€ ๋œ๋‹ค. ํŒŒ์›Œ๋ฅผ ๋ณด์กดํ•˜๊ธฐ ์œ„ํ•ด์„œ Taptic Engine ์€ ์ดˆ ๋‹จ์œ„์˜ ์งง์€ ์‹œ๊ฐ„๋™์•ˆ ์ด ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•˜๊ฑฐ๋‚˜ ํ”ผ๋“œ๋ฐฑ์„ ํŠธ๋ฆฌ๊ฑฐํ• ๋•Œ๊นŒ์ง€ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค.
- ๋งŒ์•ฝ, prepare() ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•œ ๋‹ค์Œ ์ฆ‰์‹œ ํ”ผ๋“œ๋ฐฑ์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๋ฉด ์‹œ์Šคํ…œ์€ Taptic Engine ์„ ์ค€๋น„๋œ ์ƒํƒœ๋กœ ์ „ํ™˜ํ•  ์‹œ๊ฐ„์ด ์ถฉ๋ถ„ํ•˜์ง€ ์•Š๊ณ , ์ง€์—ฐ์‹œ๊ฐ„์ด ์ค„์–ด๋“ค์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค. ๋ฐ˜๋ฉด์—, prepare() ๋ฉ”์„œ๋“œ๋ฅผ ๋„ˆ๋ฌด ์ผ์ฐ ํ˜ธ์ถœํ•˜๋ฉด ํ”ผ๋“œ๋ฐฑ์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๊ธฐ ์ „์— Taptic Engine ์€ ๋‹ค์‹œ ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” ์ƒํƒœ๊ฐ€ ๋œ๋‹ค.

(์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณด๊ฒŒ๋˜๋ฉด ๋ฒ„ํŠผ์ด ํด๋ฆญ๋˜๊ธฐ ์ „์— generator ๋ฅผ ์ค€๋น„ํ•˜๊ณ , ์•ก์…˜์ด ์‹คํ–‰๋  ๋•Œ ํŠธ๋ฆฌ๊ฑฐํ•˜๋Š” ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.)

3. [Triggering Feedback](https://developer.apple.com/documentation/uikit/uifeedbackgenerator#2555415)
- ๊ฐ feedback generator ํ•˜์œ„ ํด๋ž˜์Šค๋Š” ๊ณ ์œ ํ•œ ํŠธ๋ฆฌ๊ฑฐ ๋ฐฉ๋ฒ•์„ ๊ฐ€์ง„๋‹ค. ํŠธ๋ฆฌ๊ฑฐ ํ•˜๊ธฐ ์œ„ํ•ด์„œ [impactOccurred()](https://developer.apple.com/documentation/uikit/uiimpactfeedbackgenerator/2374287-impactoccurred),ย [selectionChanged()](https://developer.apple.com/documentation/uikit/uiselectionfeedbackgenerator/2374284-selectionchanged), orย [notificationOccurred(_:)](https://developer.apple.com/documentation/uikit/uinotificationfeedbackgenerator/2369826-notificationoccurred) ์„ ์ ์ ˆํ•˜๊ฒŒ ํ˜ธ์ถœํ•ด์•ผํ•œ๋‹ค.
- ์ด๋Ÿฐ ๋ฉ”์„œ๋“œ๋“ค์„ ํ˜ธ์ถœํ•ด๋„ haptic ์ด ์ง์ ‘ ์žฌ์ƒ๋˜์ง€๋Š” ์•Š๋Š”๋‹ค. ๋Œ€์‹  ์‹œ์Šคํ…œ์— ์ด๋ฒคํŠธ๋ฅผ ์•Œ๋ฆฐ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ์‹œ์Šคํ…œ์€ applicationโ€™s state, amount of bateery power remaining , factors ๋“ค์„ ๊ธฐ๋ฐ˜์œผ๋กœ haptic ์„ ์žฌ์ƒํ• ์ง€ ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค.

---

**For example, haptic feedback is currently played only:**

- On a device with a supported Taptic Engine(iPhone 6s ์ดํ›„์˜ ๋ชจ๋“  iPhone ๋ฐ Apple watch, MacBook, Trackpad ๋“ฑ์— ํƒ‘์žฌ๋˜์–ด์žˆ์Œ)
- When the app is running in the foreground
- When the System Haptics setting is enabled

---

- ํ”ผ๋“œ๋ฐฑ์„ ์žฌ์ƒํ• ์ง€ ์—ฌ๋ถ€์— ๋Œ€ํ•ด์„œ ์‹œ์Šคํ…œ์„ ์‹ ๋ขฐํ•ด๋ผ. ์กฐ๊ฑด๋ถ€๋กœ ํ”ผ๋“œ๋ฐฑ์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๋ ค ํ•˜์ง€ ๋ง์•„๋ผ.
4. [Releasing the Generator](https://developer.apple.com/documentation/uikit/uifeedbackgenerator#2555460)ย (optional).
- ๋” ์ด์ƒ ์ค€๋น„๋œ generator ํ•„์š”์—†์œผ๋ฉด generatro object ์˜ ์ฐธ์กฐ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ , ์‹œ์Šคํ…œ์—์„œ deallocate ํ•˜๋„๋ก ํ•œ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด Taptic Engine ์„ ๋‹ค์‹œ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ƒํƒœ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

(์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณด๊ฒŒ๋˜๋ฉด ํ–…ํ‹ฑ ๋™์ž‘ ์ดํ›„ ๋งˆ์ง€๋ง‰์— generator ์— nil ์„ ํ• ๋‹นํ•˜์—ฌ ํ•ด์ œํ•˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.)

- generator ์— ์•„๋ฌด๋Ÿฐ ์ฐธ์กฐ๊ฐ€ ์—†์œผ๋ฉด ์‹œ์Šคํ…œ์€ deallocate ํ•œ๋‹ค.

## ๐Ÿ‘์‹œ์ž‘ํ•˜๊ธฐ

- ๋ชจ๋“  ํ–…ํ‹ฑ์„ ์ฒดํ—˜ํ•ด๋ณด๊ธฐ ์œ„ํ•จ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฒฝ์šฐ์— ๋”ฐ๋ผ generator ๋ฅผ prepare ํ•˜๊ฑฐ๋‚˜ release ํ•˜๋Š” ์ฝ”๋“œ๋Š” ์—†์„ ์ˆ˜ ์žˆ๋‹ค.

### UINotificationFeedbackGenerator

```swift
import UIKit

class ViewController: UIViewController {

// MARK: - Properties

var notificationFeedbackGenerator: UINotificationFeedbackGenerator?
// ...

// MARK: - View Life Cycle

override func viewDidLoad() {
super.viewDidLoad()

setNotificationFeedbackGenerator()
}

// UINotificationFeedbackGenerator action
@IBAction func touchNotificationSuccessButton(_ sender: Any) {
notificationFeedbackGenerator?.notificationOccurred(.success)
}

@IBAction func touchNotificationWarningButton(_ sender: Any) {
notificationFeedbackGenerator?.notificationOccurred(.warning)
}

@IBAction func touchNotificationErrorButton(_ sender: Any) {
notificationFeedbackGenerator?.notificationOccurred(.error)
}
}

// MARK: - Extensions

extension ViewController {
/// set UINotificationFeedbackGenerator
private func setNotificationFeedbackGenerator() {
notificationFeedbackGenerator = UINotificationFeedbackGenerator()
notificationFeedbackGenerator?.prepare()
}
}
```

### UIImpactFeedbackGenerator

```swift
import UIKit

class ViewController: UIViewController {

// MARK: - Properties

// ...
var impactFeedbackGenerator: UIImpactFeedbackGenerator?

// MARK: - View Life Cycle

override func viewDidLoad() {
// ...
}

// UIImpactFeedbackGenerator action
@IBAction func touchImpactHeavyButton(_ sender: Any) {
impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
impactFeedbackGenerator?.impactOccurred()

impactFeedbackGenerator = nil
}

@IBAction func touchImpactMediumButton(_ sender: Any) {
impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
impactFeedbackGenerator?.impactOccurred()

impactFeedbackGenerator = nil
}

@IBAction func touchImpactLightButton(_ sender: Any) {
impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)
impactFeedbackGenerator?.impactOccurred()

impactFeedbackGenerator = nil
}
}
```

### UISelectionFeedbackGenerator

```swift
import UIKit

class ViewController: UIViewController {

// MARK: - Properties

// ...
var selectionFeedbackGenerator: UISelectionFeedbackGenerator?

// MARK: - View Life Cycle

override func viewDidLoad() {
// ..
}

// UISelectionFeedbackGenerator action
@IBAction func touchSelectionButton(_ sender: Any) {
selectionFeedbackGenerator = UISelectionFeedbackGenerator()
selectionFeedbackGenerator?.selectionChanged()

selectionFeedbackGenerator = nil
}
}

```

### ๋ทฐ

- ๋ฒ„ํŠผ์„ ์ƒ์„ฑํ•ด์„œ Haptic ์„ ์ฒดํ—˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์„ฑ

---

### ๊นƒํ—ˆ๋ธŒ :

[GitHub - hyun99999/UIFeedbackGeneratorTutorial-iOS: ๐Ÿ‘†UIFeedbackGeneratorTutorial ํ–…ํ‹ฑ ๋Œ€์ž‘์ „](https://github.com/hyun99999/UIFeedbackGeneratorTutorial-iOS)

[GitHub - 28th-SOPT-iOS-CloneCoding/MiraClone-KimHyunGyu: ๐Ÿงš ์•„์š” ๋ฏธ๋ผํด๋ก ์ฝ”๋”ฉ ๊น€ํ˜„๊ทœ](https://github.com/28th-SOPT-iOS-CloneCoding/MiraClone-KimHyunGyu)

---

### ์ฐธ๊ณ  :

[iOS ) Haptic Feedback](https://zeddios.tistory.com/726)

[Haptics - User Interaction - iOS - Human Interface Guidelines - Apple Developer](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/haptics/)