在 iOS 上的 UINavigationItem 上设置 2 行标题?
我想设置 UINavigationItem 的标题,使其显示 2 行标题,并且两行的字体都比正常字体小。我确实在其他应用程序(例如邮件)上看到过这种效果,但我不知道如何让它发挥作用。
我尝试设置提示,这绝对不是我想要的,我希望导航栏保持相同的高度,但文本变小并允许两行。
默认情况下这是可能的还是我需要自己的自定义视图来实现它?
I want to set a UINavigationItem's title such that it displays a 2 line title with both lines in a smaller font than normal. I've definitely seen this effect on other apps such as Mail, but I can't figure out how to get it to work.
I tried setting a prompt, that's definitely not what I want, I want the Nav Bar to stay the same height but have the text get smaller and allow two lines.
Is this possible by default or do I need my own custom view to achieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将
titleView
设置为自定义视图,例如具有所需字体的 UILabel。要使其成为 2 行标签,请确保将numberOfLines
设置为 2。You can set
titleView
to a custom view, for example a UILabel with the desired font. To make it a 2-line label, make sure you setnumberOfLines
to 2.除了设置
Prompt
之外,您需要的是一个自定义navigationBar
,其中的UILabel
设置numberOfLines
属性到 2。或者,您可以使用 2 个 UILabel。Other than setting the
Prompt
, what you are looking for is a customnavigationBar
with aUILabel
setting thenumberOfLines
property to 2. Alternatively, you can use 2UILabel
's.