【问题标题】:HUD with multiple lines具有多行的 HUD
【发布时间】:2012-08-09 12:03:33
【问题描述】:

如何制作具有多行的 HUD? 他是我的代码,但是labelText是一行

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];

【问题讨论】:

标签: iphone objective-c cocoa-touch hud


【解决方案1】:

使用 detailsLabelText 方法,即

HUD.detailsLabelText = @"your next line here"

您可以使用 detailsLabelFont 更改样式。

【讨论】:

  • 太聪明了!完美解决了我的问题!
  • 从 v1.0.0 开始(可能更早) detailsLabelText 已被弃用,建议您使用 detailsLabel.text
【解决方案2】:

最简单的方法(扩展 Jon Madison 的答案):

hud.labelText = @"Your first line of text is";
hud.detailsLabelText = @"followed by your next line of text";
hud.detailsLabelFont = hud.labelFont;

【讨论】:

    【解决方案3】:

    不确定,但您需要修改MBProgressHUD.m 文件的代码。

    在MBProgressHUD.m文件中,有一个方法- (void)setupLabels。在该方法中,创建了一个标签。通过设置其属性 numberOfLines 来制作该标签的多行标签。

    例如:

    label.numberOfLines = 2;

    希望它有效..

    【讨论】:

    • 您确定该功能吗?我没有在MBProgressHUD.m
    • 是的,我确定...它在 MBProgressHUD.m 文件中
    • 唯一的尊重是版本。您正在使用 0.4
    • @Luda:尝试从labelText字符串变量中找出一个设置其文本的标签...
    • 我会下载更新的版本
    猜你喜欢
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 2012-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多