如何在 tableviewcell 中使用不同的字体制作不同的单词

发布于 2024-12-21 13:32:38 字数 179 浏览 0 评论 0原文

我有一个表格视图。其中一行有不同的行 为此,我编写了这样的代码:

cell.textLabel.text=@"Hi this is PRASAD";

这里我只想要具有不同字体和样式的“PRASAD”。必须是粗体。

我必须在 textlabel 中实现什么逻辑?

I have a table view. in that one row is having different lines
for that i wrote code like this:

cell.textLabel.text=@"Hi this is PRASAD";

here i want only "PRASAD" with different font & must be in BOLD.

what logic i have to implement in textlabel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

携君以终年 2024-12-28 13:32:38

你不能。 UILabel 不能具有多种字体特征。唯一的选择是为单元格创建一个自定义视图,该视图可以是 Web 视图,也可以是多个标签。

You can't. A UILabel cannot have multiple font characteristics. The only option is to make a custom view for the cell that is either a webview or multiple labels.

悲歌长辞 2024-12-28 13:32:38

使用 NSAttributedString 保存文本,使用 CoreText 进行渲染。
它是快速&它可以工作,但肯定不像 UILable 那么容易:)

查看 Apple 的核心文本示例代码

还有一个 gitHub 项目“NSAttributedString + HTML”查找它。
gitHub 上也有很多 CoreText 项目。

Use NSAttributedString for holding text and CoreText for rendering.
It is fast & it works but surely not as easy as UILable :)

Look at the core text sample code by Apple

There is also a gitHub project "NSAttributedString + HTML" look it up.
There are a lot of CoreText projects as well on gitHub.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文