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

发布于 2024-09-07 01:20:00 字数 1015 浏览 1 评论 0原文

如何像 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极致的悲 2024-09-14 01:20:00

创建一个包含进度条和标签的自定义视图,然后在视图控制器的导航项上设置 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文