• MBProgressHUD自定义customView


    MBProgressHUD 自定义customView 比较简单代码如下:

    MBProgressHUD _customHud = [[MBProgressHUD alloc]initWithFrame:MAIN_SCREEN_BOUNDS]; 
    _customHud.margin
    = 0;
    _customHud.customView
    = self.noticeView;
    _customHud.mode
    = MBProgressHUDModeCustomView;

    但是你很快就会发现自定义view的frame值不管你怎么设置,都不对,都不是想要的结果上github上,查了一下得到一下结果:

    1.首先自定义view必须重写:intrinsicContentSize方法

    2.手动设置 translatesAutoresizingMaskIntoConstraints = NO

    完整代码如下:

    #import "GLNoticeView.h"
    
    @implementation GLNoticeView
    
    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect {
        // Drawing code
    }
    */
    - (CGSize)intrinsicContentSize {
        CGFloat contentViewH = 200;
        CGFloat contentViewW = MAIN_SCREEN_WIDTH - 40;
        return CGSizeMake(contentViewW, contentViewH);
    }
    
    
    - (instancetype)initWithFrame:(CGRect)frame {
       self = [[NSBundle mainBundle] loadNibNamed:@"GLNoticeView" owner:nil options:nil].firstObject;
        self.translatesAutoresizingMaskIntoConstraints = NO;
        self.layer.cornerRadius = 4;
        self.layer.masksToBounds = YES;
        return self;
    }
    
    @end

    至此问题完美解决。

  • 相关阅读:
    openlayers wfs获取要素
    ArcEngine 直连连接SDE
    arcgis中的 style和serverstyle
    C#开源大全
    C#+ArcEngine 序列化和反序列化AE对象
    C# lazy加载
    Testing 理论测试(三)
    软件开发模型种类(7)
    Testing理论测试题(二)
    Testing 理论测试题(一)
  • 原文地址:https://www.cnblogs.com/TengSys/p/6739121.html
Copyright © 2020-2023  润新知