取消选择文本后 UILabel 字体切换回来

发布于 2024-11-17 10:49:37 字数 103 浏览 5 评论 0原文

我有一个问题:我想更改 UILabel 中的字体。当我在 UILabel 中选择文本并更改字体时,它会起作用,但是当我取消选择文本时,字体会恢复为默认值。

有人有主意吗? 谢谢

I have a problem: I want to change the font in my UILabel. When I select the text in the UILabel and I change the font it works, but when I unselect the text, the font comes back to defaut.

Someone have an idea?
Thx

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

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

发布评论

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

评论(3

邮友 2024-11-24 10:49:37

你是在界面生成器中做的吗?但它非常简单。您也可以使用代码来做到这一点。

lblName.font= [UIFont fontWithName:@"Arial" size:15];

像这样的东西。

Are you doing it in interface builder? It is very straight forward though. You can also do that using code.

lblName.font= [UIFont fontWithName:@"Arial" size:15];

Something like this.

带刺的爱情 2024-11-24 10:49:37
UIFont *myFont = [ UIFont fontWithName: @"Arial" size: 18.0 ];
textLabel.font  = myFont;

这应该会改变字体,但是你在 IB 中改变它吗?它还取决于您选择的字体类型。它在 IB 中可能不可见,并且在设备上的呈现取决于其上可用的字体。

UIFont *myFont = [ UIFont fontWithName: @"Arial" size: 18.0 ];
textLabel.font  = myFont;

This should change the font, however Are you changing it in IB? Also it depends on the type of font you are selecting. It may not be visible in IB and rendering on device depends on the fonts available on it.

夏有森光若流苏 2024-11-24 10:49:37

labelName.font=[UIFont boldSystemFontOfSize:18]; 或可以根据需要指定任何其他字体样式。

labelName.font=[UIFont boldSystemFontOfSize:18]; or any other font style can be assigned as desired.

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