zoukankan      html  css  js  c++  java
  • IOS AutoLayout 遍历修改约束

    self.cvv2View.hidden = YES;

            self.periodView.hidden = YES;

            

            [self.contentView.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *constraint, NSUInteger idx, BOOL *stop)

             {

                 if ((constraint.firstItem ==self.periodView)&&(constraint.firstAttribute == NSLayoutAttributeTop))

                 {

                     constraint.constant = 0;

                 }

                else if ((constraint.firstItem ==self.cvv2View)&&(constraint.firstAttribute == NSLayoutAttributeTop))

                 {

                     constraint.constant = 0;

                 }

            }];

     

            

            [self.cvv2View.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *constraint, NSUInteger idx, BOOL *stop)

             {

                 if ((constraint.firstItem ==self.cvv2View)&&(constraint.firstAttribute == NSLayoutAttributeHeight))

                 {

                     constraint.constant = 0;

                 }

            }];

            

            [self.periodView.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *constraint, NSUInteger idx, BOOL *stop)

             {

                 if ((constraint.firstItem ==self.periodView)&&(constraint.firstAttribute == NSLayoutAttributeHeight))

                 {

                     constraint.constant = 0;

                 }

             }];

     

     

    1.并不是所有的时候都是  firstItem  跟 firstAttribute (比如trailing的时候)(firstItem.firstItemAttribute == secondItem.secondItemAttribute * multiplier + constant

    2.高度的时候自己遍历自己,top buttom trailing的时候是父亲遍历儿子(可以通过xib里面的autolayout分布来回忆)

    ///////

    删除某个约束

     

    -

    WS(ws)

        

        for( NSLayoutConstraint * con in self.progressBgView.constraints )

        {

            if ((con.firstItem == ws.progressBgView)&&(con.firstAttribute == NSLayoutAttributeHeight))

            {

                [ws.progressBgView removeConstraint:con];

            }

        }

  • 相关阅读:
    PHP图像处理
    PHP文件上传
    PHP文件编程
    PHP面向对象
    【Codeforces Round #694 (Div. 1) B】Strange Definition
    【Codeforces Round #694 (Div. 2) C】Strange Birthday Party
    【Codeforces Round #693 (Div. 3) F】New Year's Puzzle
    【Codeforces Round #693 (Div. 3) G】Moving to the Capital
    【Codeforces Round #695 (Div. 2) E】Distinctive Roots in a Tree
    【Codeforces Round #695 (Div. 2) D】Sum of Paths
  • 原文地址:https://www.cnblogs.com/rollrock/p/5390816.html
Copyright © 2011-2022 走看看