iOS 用代码来更新约束

来源:互联网 发布:长整型数据 编辑:程序博客网 时间:2024/05/29 18:55

 //遍历footerview约束(一般高,宽)

            NSArray* constrains = self.footerView.constraints;

            for (NSLayoutConstraint* constraint in constrains) {

                if (constraint.firstAttribute == NSLayoutAttributeHeight) {

                    constraint.constant = 0.0;

                }

            }

            

           //遍历view约束,找到属于webView的约束

            NSArray* constrains2 = self.view.constraints;

            for (NSLayoutConstraint* constraint in constrains2) {

                if (constraint.secondItem == self.webView) {

                    //据底部0

                    if (constraint.firstAttribute ==NSLayoutAttributeBottom) {

                        constraint.constant = 0.0;

                        

                    }

                }

            }

0 0