0

UIView の最大高さを設定するために、次の Visual Format Language (VFL) を使用しています。

// this is here to stop the auto layout from reporting that the guides has
// ambiguous layout
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[topGuide]|" options:0 metrics:nil views:views]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[bottomGuide]|" options:0 metrics:nil views:views]];


// center the stop view in the super view, both lines below are needed
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(>=12)-[stopView(<=400)]-(>=12)-|"
                                                                  options: 0
                                                                  metrics:nil
                                                                    views:views]];
// set the height to a ratio of the width
NSLayoutConstraint *con2 = [NSLayoutConstraint constraintWithItem:stopView
                                                        attribute:NSLayoutAttributeWidth
                                                        relatedBy:0 toItem:stopView
                                                        attribute:NSLayoutAttributeHeight
                                                       multiplier:0.66667f constant:0];
[self.view addConstraint:con2];

しかし、VFL はゼロから高さを開始します。制約が満たされると停止し、次の画像が生成されます。

高さはゼロから始まります.

Visual Format String を@"|-(>=12)-[stopView(<=400,>=100)]-(>=12)-|"100 から始まる高さに変更すると、次のようになります。

高さは100から始まります

高さを 400 から開始し、制約を満たすまで下げるには、どの VFL を追加できますか?

4

0 に答える 0