6

How can I make HUD that has multiple lines? He is my code, but the labelText is one line

HUD = [MBProgressHUD showHUDAddedTo:[[TTNavigator navigator] window] animated:YES];
HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"noImage.png"]];
HUD.mode = MBProgressHUDModeCustomView;
HUD.delegate = self;
HUD.labelText = @"text1 \n text2";
[HUD hide:YES afterDelay:3];
Luda
  • 7,282
  • 12
  • 79
  • 139

3 Answers3

15

use detailsLabelText method, i.e.

HUD.detailsLabelText = @"your next line here"

you can change the style using detailsLabelFont.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Jon Madison
  • 435
  • 6
  • 16
6

Easiest way (expanding on Jon Madison's answer):

hud.labelText = @"Your first line of text is";
hud.detailsLabelText = @"followed by your next line of text";
hud.detailsLabelFont = hud.labelFont;
Fateh Khalsa
  • 1,326
  • 1
  • 15
  • 19
2

Not sure but you need to modify the MBProgressHUD.m file's code.

In MBProgressHUD.m file, there is a method - (void)setupLabels. In that method, a label is created. Make that label multiline label by setting its property numberOfLines.

Ex:

label.numberOfLines = 2;

Hope it works..

Maulik
  • 19,348
  • 14
  • 82
  • 137