如何自定义代码块(Code Block)样式 #71
-
|
如图所示,MarkdownView貌似是为 macOS 优先设计,在移动端中的 Table
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
|
这个是 Code Block 吧 貌似不是 Table Code Block 是支持自定义的 |
Beta Was this translation helpful? Give feedback.
-
感谢回复。我对 不知道该如何定义
|
Beta Was this translation helpful? Give feedback.
-
@resetsix 你所谓的 Table 是这个嘛?还是哪一块?你的截图中其实没有出现 Table |
Beta Was this translation helpful? Give feedback.
-
对的是代码块,抱歉没有阐述清楚。 代码块的 header 与 body |
Beta Was this translation helpful? Give feedback.
-
这里没有 header 和 body 的概念 就是一个块 @resetsix 自定义代码块需要自定义一个 Style 类型 然后遵循 参考
|
Beta Was this translation helpful? Give feedback.
-
|
@LiYanan2004 好的谢谢,我研究一下。 |
Beta Was this translation helpful? Give feedback.
-
|
@LiYanan2004 你好我想请教一下,为什么 Markdown(data)
// .markdownTheme(.gitHub)
.markdownBlockStyle(\.codeBlock) { configuration in
configuration.label
.padding()
.background(Color.pink)
}MarkdownView(data)
// .markdownTheme(.gitHub)
// .markdownMathRenderingEnabled()
.markdownBlockStyle(\.codeBlock) { configuration in
configuration.label
.padding()
.background(Color.pink)
}补充:我才发现文档里没有 |
Beta Was this translation helpful? Give feedback.
-
|
文件导了多个 markdown 的库写demo,xcode类型提示串味了
|
Beta Was this translation helpful? Give feedback.




这里没有 header 和 body 的概念 就是一个块
@resetsix 自定义代码块需要自定义一个 Style 类型 然后遵循
CodeBlockStyle协议参考
DefaultCodeBlock(在项目里有源码)SwiftUI.ButtonStyle