简单实用的基于MBProgressHUD的弹框提示

2019-10-09  本文已影响0人  布呐呐u
1)使用场景

项目工程中,时常用到弹框提示,基于MBProgressHUD简单封装的实用弹框提示。

2)源码分享
//基于MBProgressHUD,故使用前,请自行导入MBProgressHUD三方库
+ (void)showMessageWithTitle:(NSString *)title withContent:(NSString *)content withDelay:(NSTimeInterval)delay
{
    dispatch_async(dispatch_get_main_queue(), ^{
    MBProgressHUD *progressView = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
    progressView.bezelView.color = [UIColor darkGrayColor];
    progressView.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    progressView.contentColor = [UIColor whiteColor];
    progressView.mode = MBProgressHUDModeText;
    progressView.label.text = title;
    progressView.detailsLabel.text = content;
    [progressView hideAnimated:YES afterDelay:delay];
    });
}
3)使用方法
//带Title或不带Title,文字自适应
[MessageUtil showMessageWithTitle:@"Title" withContent:@"字数自适应测试" withDelay:2];
4)相关截图
图片展示1.png 图片展示2.png
上一篇下一篇

猜你喜欢

热点阅读