iosobjective-cmacosmbprogresshud

Showing toast message with MBProgressHUD in mac os


I am showing toast message using MBProgressHUD but with toast message getting some view with it Below is code is using

HUD image

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window.contentView animated:YES];;

// Configure for text only and offset down
hud.mode = MBProgressHUDModeText;
hud.labelText = @"some message......";
hud.margin = 10.f;
hud.yOffset = 200.f;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:20];

Solution

  • For macOS Using MBProgressHud you can show like this

    MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:window.contentView];
                hud.mode = MBProgressHUDModeText;
                hud.labelFont = [NSFont systemFontOfSize:13.0];
                hud.margin = 8.f;
                hud.opacity = 0.7;
                hud.yOffset = NSHeight(window.frame)/2-60;
                hud.cornerRadius = 4.0;
                hud.removeFromSuperViewOnHide = YES;
                hud.detailsLabelText = @"some message......";
                [window.contentView addSubview:hud];
                [hud show:YES];
                [hud hide:YES afterDelay:2.0];