Petar
Petar

Reputation: 2283

iOS autolayout visual format language translate

I have the following constraint:

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

I want to do some animation with it and therefore I need to have it parameterised. I want to have the same thing but using the API. This is what I tried but it doesn't work :

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

What I want is to have both views have equal height.

Upvotes: 0

Views: 329

Answers (1)

Fabio Felici
Fabio Felici

Reputation: 2916

Add another constraint like this and it should work:

    [NSLayoutConstraint constraintWithItem:drawerView
                                 attribute:NSLayoutAttributeHeight
                                 relatedBy:NSLayoutRelationEqual
                                    toItem:nil
                                 attribute:NSLayoutAttributeNotAnAttribute
                                multiplier:1.0
                                  constant:yourHeightValue];

Upvotes: 1

Related Questions