如何在导航栏中显示进度条,就像在iPhone中的消息应用程序中一样?
如何像 iPhone 消息应用程序一样在导航栏中显示进度条。 为此,您可以参考以下链接来显示进度条
http://www.apple。 com/iphone/features/messages.html
我尝试使用工具栏来做到这一点,但结果并不像消息应用程序中那样。
-(void) createToolbar
{
toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(95.0,15,130,47.0)];
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
ProgressView = [[UIProgressView alloc] initWithProgressViewStyle:0];
[ProgressView setProgress:0.0];
[ProgressView setFrame:CGRectMake(0,30,80,10)];
UIBarButtonItem *homeItem = [[UIBarButtonItem alloc] initWithCustomView:ProgressView];
NSArray *items = [NSArray arrayWithObjects:flexibleItem, homeItem, flexibleItem,nil];
[toolbar setItems:items animated:YES];
[self.view addSubview:toolbar];
}
上面的代码在屏幕顶部显示工具栏,进度条位于中心,但此时需要隐藏导航栏,否则工具栏显示在导航栏下方。 我需要在导航栏中显示进度条。
how to show the progressbar in navigation bar as in iphone messages application.
For that, you can refer the below link for showing progressbar
http://www.apple.com/iphone/features/messages.html
I try to do that by using toolbar but result are not as like in messages application.
-(void) createToolbar
{
toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(95.0,15,130,47.0)];
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
ProgressView = [[UIProgressView alloc] initWithProgressViewStyle:0];
[ProgressView setProgress:0.0];
[ProgressView setFrame:CGRectMake(0,30,80,10)];
UIBarButtonItem *homeItem = [[UIBarButtonItem alloc] initWithCustomView:ProgressView];
NSArray *items = [NSArray arrayWithObjects:flexibleItem, homeItem, flexibleItem,nil];
[toolbar setItems:items animated:YES];
[self.view addSubview:toolbar];
}
The above code shows the toolbar on top of screen with progress bar in center but that time it require to hide navigation bar otherwise toolbar is shown below the navigation bar.
I needs to show the progress bar in navigation bar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个包含进度条和标签的自定义视图,然后在视图控制器的导航项上设置
titleView
属性。Create a custom view that contains the progress bar and the label, and then set the
titleView
property on your view controller's navigation item.