經(jīng)過(guò)測(cè)試,目前第一種方法是可以的健提。
準(zhǔn)備工作:先設(shè)置默認(rèn)編輯器為MarkDown編輯器,然后新建一篇文章
方法一脐嫂、英文模式下輸入鍵盤Tab按鈕上方的`按鈕,復(fù)制粘貼你的代碼塊
```
let?string:String= "Swift一行代碼計(jì)算字符串的寬高(最新)"
let?size = string.boundingRect(with:CGSize(width:200, height:24), font:UIFont.systemFont(ofSize:12))
```
方法二账千、使用pre標(biāo)簽
<pre>
let?string:String= "Swift一行代碼計(jì)算字符串的寬高(最新)"
let?size = string.boundingRect(with:CGSize(width:200, height:24), font:UIFont.systemFont(ofSize:12))
</pre>
方法三匀奏、使用code標(biāo)簽
<code>
let?string:String= "Swift一行代碼計(jì)算字符串的寬高(最新)"
let?size = string.boundingRect(with:CGSize(width:200, height:24), font:UIFont.systemFont(ofSize:12))
換行的內(nèi)容會(huì)被代碼片嗎娃善?
</code>