附:iOS 使用LayoutGuide 来限制控件的位置,配合Auto Layout constraints
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[self.view addSubview:button];
[button setTranslatesAutoresizingMaskIntoConstraints: NO];
// 得到当前视图的最低基准限制,这个是对于Auto Layout constraint来说的。
id bottomGuide = self.bottomLayoutGuide;
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (button, bottomGuide);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat: @"V:[button]-20-[bottomGuide]"
options: 0
metrics: nil
views: viewsDictionary]];
[self.view layoutSubviews];
同理可以得到topLayoutGuide,这个是视图最高基准限制
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对ASPKU的支持。
注:相关教程知识阅读请移步到IOS开发频道。










