0

我有以下约束:

[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[drawerView(==tapView)]|" options:0 metrics:nil views:viewDictionary]

我想用它做一些动画,因此我需要将它参数化。我想拥有相同的东西,但使用 API。这是我尝试过的,但它不起作用:

[NSLayoutConstraint constraintWithItem:drawerView
                             attribute:NSLayoutAttributeHeight
                             relatedBy:NSLayoutRelationEqual
                                toItem:self.drawerMenuVC.tapView
                             attribute:NSLayoutAttributeHeight
                            multiplier:1.0
                              constant:0]

我想要的是让两个视图具有相同的高度。

4

1 回答 1

1

添加另一个这样的约束,它应该可以工作:

    [NSLayoutConstraint constraintWithItem:drawerView
                                 attribute:NSLayoutAttributeHeight
                                 relatedBy:NSLayoutRelationEqual
                                    toItem:nil
                                 attribute:NSLayoutAttributeNotAnAttribute
                                multiplier:1.0
                                  constant:yourHeightValue];
于 2014-11-04T16:31:38.953 回答