我们如何在导航栏中的 UIBarButtonItem 中放置两行
“正在播放”位于 UIBarButtonItem 的一行中。我必须将其分成两行,例如“Now”位于顶部,“Playing”位于底部。我编写了以下代码行:-
UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
initWithTitle:@"Now Playing"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(flipView)];
self.navigationItem.rightBarButtonItem = flipButton;
所以我想在“Now Playing”之间添加换行符。所以请帮帮我。
"Now Playing" is in One line in UIBarButtonItem. I have to put it in two lines, like "Now" is ay top and "Playing" is at bottom.I have written the following line of code:-
UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
initWithTitle:@"Now Playing"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(flipView)];
self.navigationItem.rightBarButtonItem = flipButton;
So i want to pu line break in between "Now Playing". So please help me out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,你可以。做起来相当简单。创建一个多行按钮并使用它。 “技巧”是设置 titleLabel numberOfLines 属性,使其喜欢多行。
当您指定自定义按钮类型时,它希望您配置所有内容...选定状态等,此处未显示以使答案集中于手头的问题。
Yes you can. It is fairly simple to do. Create a multiline button and use that. The "trick" is to set the titleLabel numberOfLines property so that it likes multilines.
When you specify a button type of custom it expects you to configure everything... selected state, etc. which is not shown here to keep the answer focused to the problem at hand.
您可以在栏按钮内托管一个 UIButton 作为 customView (设置栏按钮项目 customView 或者您可以直接将其拖动到 UIBarButtonItem 顶部),将其挂接到插座上,然后执行;
在我的例子中变成
You can host a UIButton as customView inside your bar button (either set the bar button item customView or you can drag one directly on top of your UIBarButtonItem), hook it up as an outlet, then do;
which in my case becomes
我自己创建了 2 张 PNG 图像,看起来不错。
I create 2 PNG images by myself, and it looks good.