Created
June 17, 2020 06:20
-
-
Save tehillim/9f03f900fbee93d1ead169a1b077de6c to your computer and use it in GitHub Desktop.
SwiftUI 에서 HTML을 보여주는 view를 간략히 만들어 보았습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // HTMLView.swift | |
| // | |
| // Created by Jèwon Bong on 2020/06/17. | |
| // Copyright © 2020 Appetizer. All rights reserved. | |
| // | |
| import SwiftUI | |
| import WebKit | |
| struct HTMLView: UIViewRepresentable { | |
| let html: String | |
| func makeUIView(context: Context) -> WKWebView { | |
| return WKWebView() | |
| } | |
| func updateUIView(_ uiView: WKWebView, context: Context) { | |
| uiView.loadHTMLString("<meta name=\"viewport\" content=\"initial-scale=1.0\" />"+html, baseURL: nil) | |
| } | |
| } | |
| struct HTMLText_Previews: PreviewProvider { | |
| static var previews: some View { | |
| HTMLView(html: String("hi!")) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment