如何从 Objective-C 中的 UILabel 文本中删除粗体?

发布于 2024-12-14 01:31:07 字数 184 浏览 1 评论 0原文

我在 UITableViewCell (单元格)中有一个 UILabel 控件(标题),其中我使用以下内容将字体设置为粗体

cell.title.font=[UIFont boldSystemFontOfSize:self.textFontSize];

如何将字体更改回正常/常规粗细?

I have a UILabel control (title) in a UITableViewCell (cell) where I set the font to bold using the following

cell.title.font=[UIFont boldSystemFontOfSize:self.textFontSize];

How do I change the font back to normal/regular weight?

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

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

发布评论

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

评论(3

心的憧憬 2024-12-21 01:31:07

您可以在 UIFont 上使用 systemFontOfSize 方法。

cell.title.font=[UIFont systemFontOfSize:self.textFontSize];

You can use the systemFontOfSize method on UIFont.

cell.title.font=[UIFont systemFontOfSize:self.textFontSize];
土豪 2024-12-21 01:31:07

我错过了什么吗?

cell.title.font=[UIFont systemFontOfSize:self.textFontSize];

Am I missing something?

cell.title.font=[UIFont systemFontOfSize:self.textFontSize];
姐不稀罕 2024-12-21 01:31:07

正如其他人所说,您确实只是将 font 重新分配给字体的非粗体版本。作为附加说明,如果您不再有 self.textFontSize 可用(或者它可能已更改),您可以这样做:

cell.title.font=[UIFont systemFontOfSize:cell.title.font.pointSize];

如果系统字体只是一个示例(并且它可以是任意的)粗体字体),那么您可以尝试获取现有字体的 familyName 并使用它来构建新的非粗体版本。

As others have said, you indeed just reassign font to a non-bold version of the font. As an additional note, if you don't have self.textFontSize available anymore (or it may have changed), you could do:

cell.title.font=[UIFont systemFontOfSize:cell.title.font.pointSize];

If the system font was just an example (and it could be an arbitrary bold font), then you could try to get the familyName of the existing font and use that in hopes of constructing a new non-bold version.

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