当我给出UITextFiled的子视图时,masnory错误,右视图mas_makeConstraints

时间:2016-03-12 07:22:06

标签: ios uitextfield rightview

这是我的代码:

  UIView *nameRightView = ({
    UIView *nameRightView = [[UIView alloc] init];
    nameRightView.bounds = CGRectMake(0, 0, 100, 34);
    nameRightView.backgroundColor = [UIColor redColor];
    nameTextField.rightView = nameRightView;
    nameTextField.rightViewMode = UITextFieldViewModeAlways;

    UIImageView *closeIv = ({
        UIImageView *closeIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"subscribe_match_filter_delete_hover"]];

// closeIv.frame = CGRectMake(7,0,34,34);使用框架,没关系!

        [nameRightView addSubview:closeIv];
        [closeIv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(nameRightView.mas_top);
            make.right.equalTo(nameRightView.mas_right).width.offset(7);
            make.bottom.equalTo(nameRightView.mas_bottom);
            make.width.equalTo(@34);
        }];

        closeIv;
    });

错误日志:

*** Assertion failure in -[MASViewConstraint addConstraintWithLayoutAttribute:], /Users/donglei/Documents/Ios/BMLOL4.4.0/Pods/Masonry/Masonry/MASViewConstraint.m:207

1 个答案:

答案 0 :(得分:0)

尝试将库中ZLDropDownMenu类的所有代码替换为项目中的类ZLDropDownMenu。它帮助我