pod导入Masonry使用Margin闪退问题

  //==============================
      __weak __typeof (self)  weakSelf = self;
    UIView *redView = [[UIView alloc]init];
    [self.view addSubview:redView];
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.view.mas_topMargin);
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(0);
        make.right.mas_equalTo(weakSelf.view.mas_right).with.offset(0);
        make.bottom.mas_equalTo(weakSelf.view.mas_bottomMargin);
    }];
    redView.backgroundColor = [UIColor redColor];

报错

-[UIView mas_topMargin]: unrecognized selector sent to instance

解决方法,在pod中修改Masonry最低支持版本为iOS 8.0即可,

A12.png

运行成功,


iPhone X

参考 Masonry v1.1.0 crash with UIView margins #461

参考Stack Overflow Set deployment target for CocoaPods's pod

你可能感兴趣的:(pod导入Masonry使用Margin闪退问题)