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

            }

        }

  • 相关阅读:
    msyqld 的 The user specified as a definer ('root'@'%') does not exist 问题
    Python加密模块-pycryptodome
    【leetcode 简单】 第一百一十题 分发饼干
    Python数据类型-字典
    Python数据类型-集合(set)
    Python数据类型-列表(list)增删改查
    Python数据类型-元组
    Python 函数系列- Str
    Linux运维之shell脚本
    python之面向对象篇6
  • 原文地址:https://www.cnblogs.com/rollrock/p/5390816.html
Copyright © 2011-2022 走看看