1.初步简单的文本显示使用
显示界面的 .m文件中
导入
#import "MBProgressHUD.h"
属性
@property (nonatomic,strong) MBProgressHUD* toastView;//弹出提示
懒加载
-(MBProgressHUD*) toastView{
if (!_toastView) {
_toastView = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
_toastView.minShowTime = 2;
[_toastView setMode:MBProgressHUDModeText];
_toastView.contentColor = [UIColor grayColor];
_toastView.bezelView.backgroundColor = [UIColor blackColor];
}
return _toastView;
}
需要提醒的方法中
//弹出toast的文字
-(void)getToastString:(NSString*)str{
self.toastView.label.text = str;
[self.toastView hideAnimated:YES];
//隐藏掉之后回执行的block
需要弹出的界面* vc_self = self;
self.toastView.completionBlock = ^{
[vc_self.toastView removeFromSuperview];
vc_self.toastView = nil;
};
}