简体   繁体   English

如何在导航栏中显示进度条,例如在iPhone中的消息应用程序中?

[英]how to show progressbar in navigation bar like in messages application in iphone?

how to show the progressbar in navigation bar as in iphone messages application. 如何像iPhone消息应用程序中那样在导航栏中显示进度条。 For that, you can refer the below link for showing progressbar 为此,您可以参考以下链接以显示进度条

http://www.apple.com/iphone/features/messages.html 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 -(无效)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. 我需要在导航栏中显示进度栏。

创建一个包含进度条和标签的自定义视图,然后在视图控制器的导航项上设置titleView属性。

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

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