Showing toast message with MBProgressHUD in mac os

不羁岁月 提交于 2019-12-13 03:33:21

问题


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

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

回答1:


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



回答2:


Code:

- (void)showLoader:(NSString*)strTitle view:(UIView*)view
{
    dispatch_async(dispatch_get_main_queue() , ^{
        MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view.window];
        [view.window addSubview:hud];
        hud.labelText = strTitle;
        [hud show:YES];
    });
}

Use like this:

[self showLoader:@"Loading.." view:self.view]



回答3:


//JUST REPLACE YOUR CODE AND CHECK

AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication] delegate];

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


来源:https://stackoverflow.com/questions/55914836/showing-toast-message-with-mbprogresshud-in-mac-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!