Hi i have a MBProgressHUD on my iPad screen. Works perfectly fine. But i want to change the label to show in three lines.Like this
self.hud = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
self.hud.frame = CGRectMake(0, 0, 120, 143);
[self.navigationController.view addSubview:self.hud];
self.hud.delegate = self;
self.hud.mode = MBProgressHUDModeAnnularDeterminate;
NSString *strloadingText = [NSString stringWithFormat:@"Loading Data.\r Please Wait.\r 1-2 Minutes"];
NSLog(@"the loading text will be %@",strloadingText);
self.hud.labelText = strloadingText;
[self.hud show:YES];
So i want the label in 3 lines
Loading Data.
Please Wait
1-2 Minutes
OR can i assign an image to the HUD?
All this should be in the labeltext. But i am ending up with only one line. How can i do that? If you need more info, please ask.Thanks.
self.hud.minSize = CGSizeMake(300, 100);
The reason why labelText differs from detailsText, I imagine because it's meant to be a very similar to UIAlertView from the title/description perspective.
The differences between the two labels is quite distinct because of their purpose, for instance:
I'd recommend not having a multi-line title, keeping it short, and using the description text.
The reason why multi-line titles do not work is because of the layoutSubviews implementation, the size is not being calculated. if you inspect MBProgressHud.m, within layoutSubviews,
Note the
-[NSString sizeWithFont: constrainedToSize: lineBreakMode:]
call for the description text; this method calculates the size required to display the text - using as many lines as necessary, whereas the-[NSString sizeWithFont:]
calculates the size required to display the text, but only up to displaying one line.I would advise against having a multi-line title, and instead provide a shorter title, with some description text to accompany it.
If you simply must have the multi-line title (all changes within MBProgressHud.m):
Replace:
With:
Hope this isn't too late to help.
I had a question like this, too !
You can set
hud.label.numberOfLines = 0;
And it works!
MBProgressHUD's detailsLabelText property is multiline but not labelText property.
So, you can try something like this
You can set detailsLabelText font by using the property detailsLabelFont.