티스토리 뷰

일단, UIKit에 있는것들을 사용하려면 'UIViewRepresentable' 을 채택해야하는건 원래 알고 있었다.

 

import Combine
import NMapsMap
import SwiftUI

struct ContentView: View {
  var body: some View {
    NaverMapView()
      .edgesIgnoringSafeArea(.all)
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}

struct NaverMapView: UIViewRepresentable {
  func makeUIView(context: Context) -> NMFMapView {
    return NMFMapView()
  }
  func updateUIView(_ uiView: NMFMapView, context: Context) {
  }
}

 

따라서 새로운 struct를 만들어서 UIViewRepresentable을 채택해주고, 

 

 

필수 함수인 makeUIView()와 updateUIView()를 채택해준다. 

그리고 some View()를 우리가 쓸 타입인 NMapView로 바꿔주면 된다. 

 

 

 

잘된다 ㅎㅎ

끝!

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함