MBprogressHUD的使用

看开发文档中,涉及到六种基础的提示框

typedef NS_ENUM(NSInteger, MBProgressHUDMode) {
	/**使用UIActivityIndi​​catorView显示进度。这是菊花默认值。 */
	MBProgressHUDModeIndeterminate,
	/** 使用圆形的饼图来显示进度。 */
	MBProgressHUDModeDeterminate,
	/** 使用水平进度条显示进度 */
	MBProgressHUDModeDeterminateHorizontalBar,
	/** 使用圆环进度视图显示进度。*/
	MBProgressHUDModeAnnularDeterminate,
	/** 自定义的view*/
	MBProgressHUDModeCustomView,
	/** 仅显示标签 */
	MBProgressHUDModeText
};

使用函数

+ (void)showToast:(NSString *)title withView:(UIView *)view {
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.mode = MBProgressHUDModeIndeterminate;
    hud.labelText = title;
    [hud hide:YES afterDelay:1];
}

运行例子:
MBprogressHUD的使用_第1张图片

    //1,设置背景框的透明度  默认0.8
  	hud.opacity = 1;

    //2,设置背景框的背景颜色和透明度, 设置背景颜色之后opacity属性的设置将会失效
    hud.color = [UIColor redColor];
    hud.color = [HUD.color colorWithAlphaComponent:1];

    //3,设置背景框的圆角值,默认是10
    hud.cornerRadius = 20.0;

    //4,设置提示信息 信息颜色,字体
    hud.labelColor = [UIColor blueColor];
    hud.labelFont = [UIFont systemFontOfSize:13];
    hud.labelText = @"Loading...";

    //5,设置提示信息详情 详情颜色,字体
    hud.detailsLabelColor = [UIColor blueColor];
    hud.detailsLabelFont = [UIFont systemFontOfSize:13];
    hud.detailsLabelText = @"LoadingLoading...";

    //6,设置菊花颜色  只能设置菊花的颜色
    hud.activityIndicatorColor = [UIColor blackColor];

    //7,设置一个渐变层
    hud.dimBackground = YES;

    //9,设置提示框的相对于父视图中心点的便宜,正值 向右下偏移,负值左上
    hud.xOffset = -80;
    hud.yOffset = -100;

    //10,设置各个元素距离矩形边框的距离
    hud.margin = 0;

    //11,背景框的最小大小
    hud.minSize = CGSizeMake(50, 50);

    //12设置背景框的实际大小   readonly
    CGSize size = HUD.size;

    //13,是否强制背景框宽高相等
    hud.square = YES;

你可能感兴趣的:(搞笑的IOS)