在 SwiftUI 中使部分文本加粗 [英] Making parts of text bold in SwiftUI

查看:46
本文介绍了在 SwiftUI 中使部分文本加粗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何仅将文本的一部分设为粗体,同时在 SwiftUI 中保持其余部分常规".

I was wondering how I would make only sections of a text bold while keep the rest 'regular' in SwiftUI.

我目前拥有:

Text("Coronavirus Disease of 2019")

并且我希望它打印出 COronaVirus Disease of 2019 并且没有'只能将某些部分加粗.

and I want it to print out COronaVirus Disease of 2019 and haven't been able to get only some parts bold.

推荐答案

Swift 5.5

Foundation 支持 Markdown.

Swift 5.5

Foundation supports Markdown.

在要加粗的字符周围添加双星号 (**).

Add double asterisks (**) arroud the characters that you want to make bold.

Text("**CO**rona**V**irus **D**isease of 20**19**")

在要斜体的字符周围添加下划线.

Add underscore arround the charachters that you want to make italic.

Text("Is this text _emphasized_?")

这篇关于在 SwiftUI 中使部分文本加粗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆