iOS三方库

iOS MBProgressView 自定义 CustomVie

2020-03-13  本文已影响0人  ZT_Story

问题

根据MBP的接口文档,我们很容易写出这样的代码

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.customView = customView;

运行起来之后,发现并不是我们想象中的样子,customView没有正常的渲染出来,frame不对
github上查询一下+仔细阅读源码

解决方案

1、自定义view中需要重写

- (CGSize)intrinsicContentSize {
    CGFloat height = 200;
    CGFloat width = 200;
    return CGSizeMake(width, height);
}

2、设置translatesAutoresizingMaskIntoConstraints属性为NO

self.translatesAutoresizingMaskIntoConstraints = NO;
上一篇下一篇

猜你喜欢

热点阅读