我想将动态文本放入栏按钮项目中,类似于《纽约时报》对其评论数量的处理方式,如下图所示。
关于如何实现此功能有什么想法吗?
最佳答案
我认为关键是 - initWithCustomView: UIBarButtonItem
的方法。
下面是伪代码,根据需要修改:
UICustomViewController *customVC = [[UICustomViewController alloc] initWithNibName:@"UICustomViewController" bundle:nil];
[customVC loadView]; //load the views, so your views won't be nil
[customVC updateText];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:customVC.view];
[[self navigationItem] setRightBarButtonItem:barButtonItem];
关于ios - iOS 栏按钮项目中的动态文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29641104/