简体   繁体   English

将文本和进度图标添加到导航栏

[英]Adding a text and progress icon to navigation bar

I would like to add a status to the navigation bar. 我想在导航栏中添加一个状态。 for example, in Whatsapp, when user changes alert settings, It display "updating" text and progress icon on the navigation bar, as shown in below image. 例如,在Whatsapp中,当用户更改警报设置时,它会在导航栏上显示“更新”文本和进度图标,如下图所示。 How do i do that? 我怎么做?

在此输入图像描述

Simple add a separate view in your XIB, something like image below 简单地在XIB中添加一个单独的视图,如下图所示

在此输入图像描述

And create IBOutlet of all the components, and then you can do something like below 并创建所有组件的IBOutlet,然后您可以执行以下操作

self.navigationItem.titleView=self.progressView; //progressView IBOutlet of the container view progressView

in viewDidLoad viewDidLoad

then you can create a function like 然后你可以创建一个像

-(void)showProgress{
   self.lblUpdate.text=@"Updating...";
   [self.indicator startAnimating];
}

-(void)hideProgress{
   self.lblUpdate.text=@"Updated";
   [self.indicator stopAnimating];
}

Make sure you make the view background color clearColor , and make the indicator to hideWhenStopped . 确保将视图背景颜色clearColor ,并使指示器hideWhenStopped为“已hideWhenStopped

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM