如何在 tableviewcell 中使用不同的字体制作不同的单词
我有一个表格视图。其中一行有不同的行 为此,我编写了这样的代码:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。
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.使用 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.