iOS在navigationItem标题中显示活动指示符和文本连接?

时间:2014-02-26 18:25:02

标签: ios objective-c

我试图在navigationItem.titleView中显示活动指示符以及“连接”文字。

我已设法显示活动指示符,但不显示文字。

我目前的代码:

self.navigationItem.titleView = nil;

UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
aiView.hidesWhenStopped = NO;
self.navigationItem.titleView = aiView;

任何想法如何实现这一目标?

1 个答案:

答案 0 :(得分:1)

尝试以下...

// first create main view
UIView *mainView = [[UIView alloc] initWithFrame:.....

// now lets create label that you need to display
UILabel *titleLabel  = [[UILabel alloc] initWithFrame:.....
titleLabel.text = @"Title here";
[mainView addSubview:titleLabel];

// now create indicator
UIActivityIndicatorView *indicator = initWithFrame:.....
[mainView addSubview:indicator];


// now add mainView to titleView
self.navigationItem.titleView = mainView;