Instead of adding an activity indicator and a label as separate views, create one composite view containing both of them, and add this composite view to the toolbar.
Create a class derived from UIView, override initWithFrame and add this code:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self configureView];
}
return self;
}
-(void)configureView{
self.backgroundColor = [UIColor clearColor];
UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityIndicator.frame = CGRectMake(0, 0, self.frame.size.height, self.frame.size.height );
activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
activityIndicator.backgroundColor = [UIColor clearColor];
[self addSubview:activityIndicator];
CGFloat labelX = activityIndicator.bounds.size.width + 2;
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(labelX, 0.0f, self.bounds.size.width - (labelX + 2), self.frame.size.height)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.font = [UIFont boldSystemFontOfSize:12.0f];
label.numberOfLines = 1;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.text = @"Loading..";
[self addSubview:label];
}
You will also have to set methods for startAnimating, stopAnimating and one for setting the label text, but hopefully you get this idea.
, :
UIProgressViewWithLabel * pv = [[UIProgressViewWithLabel alloc] initWithFrame:CGRectMake(0,0,150,25)];
, .