标签:layoutguide
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,这个是视图最高基准限制
iOS 使用LayoutGuide 来限制控件的位置,配合Auto Layout constraints
标签:layoutguide
原文地址:http://blog.csdn.net/forwardto9/article/details/45876389