MBProgressHUD to show label text in more than one line

RookieAppler picture RookieAppler · Feb 22, 2013 · Viewed 14.5k times · Source

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.

Answer

Shashikanth picture Shashikanth · Feb 22, 2013

MBProgressHUD's detailsLabelText property is multiline but not labelText property.

So, you can try something like this

MBProgressHUD * hud =  [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.frame = CGRectMake(0, 0, 120, 143);

hud.mode = MBProgressHUDModeAnnularDeterminate;
NSString *strloadingText = [NSString stringWithFormat:@"Loading Data."];
NSString *strloadingText2 = [NSString stringWithFormat:@" Please Wait.\r 1-2 Minutes"];

NSLog(@"the loading text will be %@",strloadingText);
hud.labelText = strloadingText;
hud.detailsLabelText=strloadingText2;

You can set detailsLabelText font by using the property detailsLabelFont.