HBProgressHUD的使用

MBProgressHud是第三方控件,可以进行将文件拖到自己工程中,也可以使用COCOPods.这里现附上一github地址:https://github.com/jdg/MBProgressHUD
找到资源后的就是集成到自己的工程中了。
cocopds方式:
1:终端中 cd+自己文件的路径(找到自己文件的路径,拖到终端中);
2:pod init
3:vim Podfile
4:pos install
在就是将文件拖到自己的工程中的另一中方法;

这里是提示框的类型;

     MBProgressHUDModeIndeterminate,
    /// A round, pie-chart like, progress view.
    MBProgressHUDModeDeterminate,
    /// Horizontal progress bar.
    MBProgressHUDModeDeterminateHorizontalBar,
    /// Ring-shaped progress view.
    MBProgressHUDModeAnnularDeterminate,
    /// Shows a custom view.
    MBProgressHUDModeCustomView,
    /// Shows only labels.
    MBProgressHUDModeText

上代码:

 //初始化mbproressHUD并添加到当前视图上;
    theHUD=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [self.view addSubview:theHUD];
    //设置MBProgressHUD的样式;
    theHUD.mode= MBProgressHUDModeText;
    //字体内容
    theHUD.label.text=@"Loading";
    //设置HUD背景颜色;
    theHUD.tintColor=[UIColor grayColor];
    [theHUD showAnimated:NO];
    //设置背景框的透明度;
    theHUD.alpha=0.3;
    //设置字体的大小;
    theHUD.label.font=[UIFont systemFontOfSize:15];
    //设置字体的颜色;
    theHUD.label.textColor=[UIColor redColor];
    //设置副标题;
    theHUD.detailsLabel.text=@"等待中";
    //设置动画的类型;
    theHUD.animationType=MBProgressHUDAnimationFade;
     [theHUD showAnimated:YES];
    //设置控件在现实多长时间后消失;
     [theHUD hideAnimated:YES afterDelay:10];
    //添加计时器;
    thetimer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerMethod) userInfo:nil repeats:YES];
    //开启计时器;
    [thetimer fire];
    i=0;

计时器的响应方法这里主要是设置MBprogress控件中的动画进行;

-(void)timerMethod
{
    //设置进行自增到1;
    i+=0.1;
    if (i==1)
    {
        //销毁计时器;
        [thetimer invalidate];
    }
    NSLog(@"%f",i);
 //在这里进行使用自增后的数值进行赋值;MBprogress中的属性progress属性的最大值为1;
    theHUD.progress=i; 
}








![Uploading QQ20171027-140611-HD_729416.gif . . .]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,094评论 25 709
  • 番茄炒蛋是我学会的第一道菜,是奶奶教给我的,大块的炒蛋吸收了满满番茄的香甜合着鸡蛋的浓郁,餐桌上别的菜肴我看都不再...
    pm_young阅读 3,411评论 0 0
  • 项目启动页设置其实很简单,分为以下几个步骤: 1.新建工程项目,有一个默认的(Assets.xcassets),的...
    JonnyCooper阅读 13,191评论 5 2
  • What's Swift 2.3 Swift 2.3 is a minor update from Swift 2...
    Wavky阅读 1,508评论 0 1
  • 灯会划破夜,影子会藏着秘密,自行车和我一同走过这条街道。什么夜最美之类的话从来不适合我。只有那一年四季不变的街...
    eds陈明阅读 1,747评论 0 1

友情链接更多精彩内容