取消选择文本后 UILabel 字体切换回来
我有一个问题:我想更改 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你是在界面生成器中做的吗?但它非常简单。您也可以使用代码来做到这一点。
像这样的东西。
Are you doing it in interface builder? It is very straight forward though. You can also do that using code.
Something like this.
这应该会改变字体,但是你在 IB 中改变它吗?它还取决于您选择的字体类型。它在 IB 中可能不可见,并且在设备上的呈现取决于其上可用的字体。
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.
labelName.font=[UIFont boldSystemFontOfSize:18];
或可以根据需要指定任何其他字体样式。labelName.font=[UIFont boldSystemFontOfSize:18];
or any other font style can be assigned as desired.