我试图在navigationItem.titleView
中显示活动指示符以及“连接”文字。
我已设法显示活动指示符,但不显示文字。
我目前的代码:
self.navigationItem.titleView = nil;
UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
aiView.hidesWhenStopped = NO;
self.navigationItem.titleView = aiView;
任何想法如何实现这一目标?
答案 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;