SwiftUI—使用Text視圖創(chuàng)建漂亮的富文本

原文鏈接:https://github.com/fzhlee/SwiftUI-Guide#7Text-Append

添加擴展方法+,對文本View進行拼接,實現(xiàn)富文本的藝術(shù)效果。
示例代碼:

Text("Interactive ")
    .foregroundColor(.yellow)
    .fontWeight(.heavy)
+ Text("tutorials ") //調(diào)用+號擴展方法拼接另一個文本視圖,返回一個統(tǒng)一的文本視圖
    .foregroundColor(.orange)
    .strikethrough()
+ Text("for ")
    .foregroundColor(.red)
    .italic()
+ Text("SwiftUI")
    .foregroundColor(.purple)
    .underline()
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。