在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):keitaoouchi/MarkdownView开源软件地址(OpenSource Url):https://github.com/keitaoouchi/MarkdownView开源编程语言(OpenSource Language):Swift 66.0%开源软件介绍(OpenSource Introduction):MarkdownView
How to useUIViewControllerimport MarkdownView
let md = MarkdownView()
md.load(markdown: "# Hello World!") SwiftUIimport SwiftUI
import MarkdownView
struct SampleUI: View {
var body: some View {
ScrollView {
MarkdownUI(body: markdown)
.onTouchLink { link in
print(link)
return false
}
.onRendered { height in
print(height)
}
}
}
private var markdown: String {
let path = Bundle.main.path(forResource: "sample", ofType: "md")!
let url = URL(fileURLWithPath: path)
return try! String(contentsOf: url, encoding: String.Encoding.utf8)
}
}
Optionsmd.isScrollEnabled = false
// called when rendering finished
md.onRendered = { [weak self] height in
self?.mdViewHeight.constant = height
self?.view.setNeedsLayout()
}
// called when user touch link
md.onTouchLink = { [weak self] request in
guard let url = request.url else { return false }
if url.scheme == "file" {
return false
} else if url.scheme == "https" {
let safari = SFSafariViewController(url: url)
self?.navigationController?.pushViewController(safari, animated: true)
return false
} else {
return false
}
} Experimental FeaturesThis is not stable |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论