首页 > 代码库 > 约束表达式
约束表达式
形如:
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)|
约束表达式
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。