zoukankan      html  css  js  c++  java
  • iOS 在xib或者storyboard中添加AutoLayout后,在代码中修改AutoLayout约束条件

    如果是viewControl则AutoLayout适配写在- (void)updateViewConstraints方法中修改约束;

    如果是view则AutoLayout适配 则在- (void)updateConstraints方法中修改。

    可以直接把视图的约束像拖控件一样拖成属性直接在下面的方法里更改即可

    //遍历self.myView控件中的约束,找到NSLayoutAttributeHeight控件高度这个约束关系,然后修改

    -(void)updateViewConstraints

    {


        [superupdateViewConstraints];

        NSArray *constrains = self.myView.constraints;

        for(NSLayoutConstraint *constraintin constrains){

            if(constraint.firstAttribute ==NSLayoutAttributeHeight){

                constraint.constant = 50.0;

            }

        }

    }


    注意:方法中一定要加上[super updateViewConstraints] 这句话。否则会报错
  • 相关阅读:
    CodeForces 834C
    HDU 6048
    HDU 6052
    HDU 6036
    HDU 6042
    HDU 2614 Beat(DFS)
    UESTC 1272 Final Pan's prime numbers(乱搞)
    HDU 2064 汉诺塔III(递归)
    HDU 2102 A计划(DFS)
    HDU 1069 I Think I Need a Houseboat(模拟)
  • 原文地址:https://www.cnblogs.com/DevinSMR/p/6723727.html
Copyright © 2011-2022 走看看