1 //遍历view约束(高,宽) 2 NSArray* constrains = self.View.constraints; 3 for (NSLayoutConstraint* constraint in constrains) { 4 if (constraint.firstAttribute == NSLayoutAttributeHeight) { 5 //宽高的值 6 constraint.constant = 45.0; 7 } 8 } 9 10 //遍历view约束,找到属于子view的约束 11 NSArray* constrains2 = self.view.constraints; 12 for (NSLayoutConstraint* constraint in constrains2) { 13 if (constraint.secondItem == self.table) { 14 //底部距离 15 if (constraint.firstAttribute == NSLayoutAttributeBottom) { 16 constraint.constant = 0.0; 17 18 } 19 } 20 }
内容来自网络,并部分修改,非个人原创。