如何从 Objective-C 中的 UILabel 文本中删除粗体?
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在 UIFont 上使用
systemFontOfSize
方法。You can use the
systemFontOfSize
method on UIFont.我错过了什么吗?
Am I missing something?
正如其他人所说,您确实只是将
font
重新分配给字体的非粗体版本。作为附加说明,如果您不再有self.textFontSize
可用(或者它可能已更改),您可以这样做:如果系统字体只是一个示例(并且它可以是任意的)粗体字体),那么您可以尝试获取现有字体的
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 haveself.textFontSize
available anymore (or it may have changed), you could do: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.