经过测试,目前第一种方法是可以的。
准备工作:先设置默认编辑器为MarkDown编辑器,然后新建一篇文章
方法一、英文模式下输入键盘Tab按钮上方的`按钮,复制粘贴你的代码块

```
let string:String= "Swift一行代码计算字符串的宽高(最新)"
let size = string.boundingRect(with:CGSize(width:200, height:24), font:UIFont.systemFont(ofSize:12))
```
方法二、使用pre标签

<pre>
let string:String= "Swift一行代码计算字符串的宽高(最新)"
let size = string.boundingRect(with:CGSize(width:200, height:24), font:UIFont.systemFont(ofSize:12))
</pre>
方法三、使用code标签

<code>
let string:String= "Swift一行代码计算字符串的宽高(最新)"
let size = string.boundingRect(with:CGSize(width:200, height:24), font:UIFont.systemFont(ofSize:12))
换行的内容会被代码片吗?
</code>
网友评论