除了标题之外,我们可以向 UINavigation Bar 添加其他 UILabels 吗?
我正在开发一个应用程序,其中我必须在 UINavigation Bar 上显示应用程序的状态。我将使用 UILabel 来显示状态。我想知道这是否可能?
问候, 苏米特
I am working on one app in which I have to display app's status on the UINavigation Bar. I am going to use UILabel to display the status. I was wondering whether it is possible or not ?
Regards,
Sumit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的。要做的事情是
UIView
的子类),其中包含所有标签。UILabel
UILabel
直接将视图包装在UIBarButtonItem
中initWithCustomView:myLabelsView
setRightBarButtonItem:animated:
与[myViewController.navigationController.navigationItem setRightBarButtonItem:myBarButtonItemanimated:NO] 上的
UIBarButtonItem
实例示例:
Yes. The things to do are
UIView
) which contains all your labels.UILabel
directlyUIBarButtonItem
with the help ofinitWithCustomView:myLabelsView
setRightBarButtonItem:animated:
with yourUIBarButtonItem
-instance on[myViewController.navigationController.navigationItem setRightBarButtonItem:myBarButtonItem animated:NO]
Example:
我不喜欢看到疯狂的用户界面(而且我认为您的用户也不会喜欢它 - 导航栏中没有那么多的空间或空间可以使用),但技术上正确的答案对你来说,是的,你可以:
创建一个嵌入多个标签(或任何你想要的标签)的视图,并设置你的
UINavigationItem
的 < code>titleView 属性。I don't like to see crazy user interfaces (and I don't think your users would like it either -- there isn't all that much real estate or space to work with in the navigation bar), but the technically correct answer for you here is yes you can:
Create a view with multiple labels (or whatever you want) embedded in it and set your
UINavigationItem
'stitleView
property to that.中添加这个函数
你可以在 ViewDidLoad {
// Replace titleView
}
,然后你可以在任何你想要的地方设置这个函数:
//Index at here取决于你的Naviga Controller有多少个子视图
}
You can add this function in ViewDidLoad
{
// Replace titleView
}
then, you can set this function at any place you want:
//Index at here depends on your Naviga Controller has how many subviews
}