ios MBProgressHUD的基本使用

MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:img];   

      //显示hud的模式    

hud.mode = MBProgressHUDAnimationFade;       

        //背景颜色  

  hud.color = [UIColor grayColor];       

  //主标题    

hud.labelText = @"正在加载";         

//副标题    

//    hud.detailsLabelText = @"副标题";         

//显示、隐藏时的动画样式  

  hud.animationType = MBProgressHUDAnimationZoomIn;   

      //当mode的属性是跟进度相关时,就可以设置progress的值,实现实时进度的显示    

hud.progress = 0.8;     

    // HUD的相对于父视图 x 的偏移,默认居中    

//    hud.xOffset = 50;    

//    hud.yOffset = 50;       

  //是否显示蒙板    

hud.dimBackground = YES;       

  //HUD内部视图相对于HUD的内边距    

hud.margin = 50;       

  //HUD的圆角半径    

//    hud.cornerRadius = 20;   

      //最小的显示时间    

hud.minShowTime = 3.0;       

  // HUD的最小尺寸  

  hud.minSize = CGSizeMake(300, 300);     

    // 代理中只有一个方法,即获得HUD隐藏后的时刻  

  //    hud.delegate = self;  

  // 加入到img当中  

  [img addSubview:hud];       

  [hud showAnimated:YES whileExecutingBlock:^{      

  //hud执行期间

//        NSLog(@"执行期间");  

  } onQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) completionBlock:^{      

  //hud执行完毕

//        NSLog(@"执行完毕");      

  [hud removeFromSuperview];    

}];

你可能感兴趣的:(ios MBProgressHUD的基本使用)