如果是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] 这句话。否则会报错

相关文章:

  • 2022-12-23
  • 2021-04-07
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2021-08-06
猜你喜欢
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案