Skip to content

Instantly share code, notes, and snippets.

@tehillim
Created June 17, 2020 06:20
Show Gist options
  • Select an option

  • Save tehillim/9f03f900fbee93d1ead169a1b077de6c to your computer and use it in GitHub Desktop.

Select an option

Save tehillim/9f03f900fbee93d1ead169a1b077de6c to your computer and use it in GitHub Desktop.
SwiftUI 에서 HTML을 보여주는 view를 간략히 만들어 보았습니다.
//
// 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