Masonry 当需要把某个控件进行隐藏的时候有警告的解决方案

1     //查看全文
2             [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
3                 make.top.equalTo (self.contentLabel.mas_bottom).with.offset (5);
4                 make.left.equalTo (self.contentView).with.offset (10);
5                 make.width.mas_equalTo (@60).priorityLow();
6                 make.height.mas_equalTo (@25).priorityLow();
7             }];

使用例子

如果(需要隐藏){

    //查看全文
            [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo (self.contentLabel.mas_bottom).with.offset (5);
                make.left.equalTo (self.contentView).with.offset (10);
                make.width.mas_equalTo (@60).priorityLow();
                make.height.mas_equalTo (@25).priorityLow();
            }];

}else (不需要){

 //查看全文

            [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {

                make.top.equalTo (self.contentLabel.mas_bottom).with.offset (5);

                make.left.equalTo (self.contentView).with.offset (10);

                make.width.mas_equalTo (@0).priorityHigh();

                make.height.mas_equalTo (@0).priorityHigh();

            }];

}

但是这个不是解决问题的根本方法,会有循环利用的问题,

我们如果有这样的需求可以使用uiimageview和uilabel来进行才走

只要赋值为空,自动布局就可以自动对控件进行隐藏,

如果有需要点击事件的,比方说uibutton的 可以通过用户的点击点来算出位置,然后设置背景图就可以实现

大家有需求可以咨询我,留言就行

原文地址:https://www.cnblogs.com/machao/p/4619222.html