---
# System prepended metadata

title: UIKit接入SwiftUI

---

[返回目錄](https://hackmd.io/78LEM4nRQ_uB8zOu1muVWQ)

# UIKit接入SwiftUI

先備知識
https://sarunw.com/posts/uikit-in-swiftui/

- **UIViewRepresentable** 或 **UIViewControllerRepresentable**
- 類型1
    - makeUIView
    - updateUIView
    ![](https://i.imgur.com/GDxJ0Vv.png)

- 類型2 Coordinator
    ![](https://i.imgur.com/Jl9pfsm.png)
    
    ![](https://i.imgur.com/bg3AH5W.png)


## 何時使用 coordinator
Coordinator act as delegate and dataSuorce instead of target


其他資源及參考
---
- [wrap a custom uiview](https://www.hackingwithswift.com/quick-start/swiftui/how-to-wrap-a-custom-uiview-for-swiftui)
- [makeCoordinator](https://developer.apple.com/documentation/swiftui/uiviewcontrollerrepresentable/3309742-makecoordinator)

