1. 程式人生 > >MBProgressHUD換行顯示文字

MBProgressHUD換行顯示文字

-(void)showToast:(NSString *)string{

    [MBProgressHUDhideAllHUDsForView:self.viewanimated:YES];

AppDelegate *app = (AppDelegate *)[UIApplicationsharedApplication].delegate;

MBProgressHUD *hud = [MBProgressHUDshowHUDAddedTo:app.windowanimated:YES];

    hud.mode = MBProgressHUDModeText;

//    hud.labelText = string;

    hud.detailsLabelText = string;

    hud.detailsLabelFont = [UIFontfontWithName:@"Arial"size:16];

    [hud showAnimated:YESwhileExecutingBlock:^{

sleep(2);

    } completionBlock:^{

if ([[[UIApplicationsharedApplication]windows] count] > 1) {

            [MBProgressHUDhideAllHUDsForView:[[[UIApplication

sharedApplication]windows]objectAtIndex:1] animated:YES];

        }else{

            [MBProgressHUDhideAllHUDsForView:self.viewanimated:YES];

        }

    }];

}