首页 > SnapKit使用snp_updateConstraints更新CenterX失败

SnapKit使用snp_updateConstraints更新CenterX失败

我在使用SnapKit进行AutoLayout布局的时候,首先先对一个LineView进行布局

        let lineView = UIView()
        lineView.tag = 99
        lineView.backgroundColor = UIColor(hexString: "f5fc9b")
        self.channelTitleScrollView.addSubview(lineView)
        lineView.snp_makeConstraints { (make) in
            make.height.equalTo(2)
            make.bottom.equalTo(tempBtn)
            make.centerX.equalTo(tempBtn)
            make.width.equalTo(tempBtn)
        }

当我点击了另外一个按钮的时候,需要将这个LineView移动到相应的按钮下面,我使用的是

            lineView.snp_updateConstraints(closure: { (make) in
                make.centerX.equalTo(selectBtn)
                make.width.equalTo(selectBtn)
            })

但是这段代码执行以后,AutoLayout错误
经过注释后发现,width可以实现,但是CenterX冲突了,updateConstraints不能更新CenterX么?

【热门文章】
【热门文章】