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             }];

使用例子布局

若是(须要隐藏){ui

    //查看全文
            [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 (不须要){spa

 //查看全文

            [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();

            }];

 

}code

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

咱们若是有这样的需求能够使用uiimageview和uilabel来进行才走事件

只要赋值为空,自动布局就能够自动对控件进行隐藏,it

若是有须要点击事件的,比方说uibutton的 能够经过用户的点击点来算出位置,而后设置背景图就能够实现io

你们有需求能够咨询我,留言就行class

相关文章
相关标签/搜索