如何以编程方式在故事板中实现以下约束?
答案 0 :(得分:0)
有很多不同的方法可以做到这一点。
最简单的方法可能是使用Visual Format Language https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/VisualFormatLanguage/VisualFormatLanguage.html
使用此功能,您可以使用文本“绘制”布局,它将应用约束。
像这样......
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-[tableView]-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(tableView)]];
你可以用VFL做很多不同的事情。
您最好的选择是查看文档或购买图书。 (我推荐Ray Wenderlich的iOS7 by Tutorials)。我与他无关,但我买了这本书并从那里学习了AutoLayout。