ios - 向导航栏添加文本和进度图标

标签 ios

我想给导航栏添加一个状态。例如,在 Whatsapp 中,当用户更改警报设置时,它会在导航栏上显示“正在更新”文本和进度图标,如下图所示。 我该怎么做?

enter image description here

最佳答案

简单地在您的 XIB 中添加一个单独的 View ,如下图所示

enter image description here

并创建所有组件的 IBOutlet,然后您可以执行如下操作

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

viewDidLoad

然后你可以创建一个像这样的函数

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

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

确保将 View 背景色设置为clearColor,并将指示器设置为hideWhenStopped

希望对您有所帮助。

关于ios - 向导航栏添加文本和进度图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18320543/

相关文章:

ios - 试图让后台获取工作

ios - NSArray 按组枚举

iphone - 在 UINavigationbar 中显示通知标记,如计数器

iphone - 性能 : Quartz2D vs OpenGL ES (GLKit)

ios - Firebase Google 登录 : get user location

ios - 在 Swift 中使用 AlamoFire 创建泛型方法

ios - 动态添加对象到 UITableView 单元格

ios - UITableView scrollViewDidScroll 在动画上触发

ios - animateWithDuration 在升级到 xcode 4.6 后导致 ios4 上的触摸事件出现问题

ios - 如何设置 UITextField 的自定义光标位置?