autolayout 动态的修改Frame

来源:互联网 发布:js基本数据类型 编辑:程序博客网 时间:2024/06/04 18:12

ps一下,由于autolayout设定了约束,但是想让一个View从一点到另外一点,代码中直接修改view的frame是行不通的

oginViewTopConstraint = [NSLayoutConstraint constraintWithItem:self.loginView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:20];//定义新约束

    [self.view removeConstraint:self.topConstraint];//移除旧约束

    [self.view addConstraint:loginViewTopConstraint];//添加新约束

    [self.view layoutIfNeeded];//使约束生效


0 0
原创粉丝点击