首页 > 代码库 > 约束表达式

约束表达式

形如:

    NSDictionary *views = NSDictionaryOfVariableBindings(_userNameView,_pwdView);    NSDictionary *metrics = @{@"hDistance":@"15",@"vDistance":@"20",@"vHeight":@"40"};    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-hDistance-[_userNameView]-hDistance-|" options:0 metrics:metrics views:views]];    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-vDistance-[_userNameView(vHeight)]|" options:0 metrics:metrics views:views]];        [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-hDistance-[_pwdView]-hDistance-|" options:0 metrics:metrics views:views]];//    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-80-[_pwdView(_userNameView)]|" options:0 metrics:metrics views:views]];    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_userNameView]-20-[_pwdView(_userNameView)]|" options:0 metrics:metrics views:views]];

效果:

改为:

        V:|-vDistance-[_userNameView(vHeight)]-20-_pwdView(_userNameView)|

 

约束表达式