0
我想将两个视图(本例中为UIButton
实例)对齐。我想要第一个按钮左对齐到它的超级视图,这很容易,但我没有看到一种方法来使第二个按钮与第一个按钮对齐,而不引用第一个按钮的宽度。使用FLKAutoLayout对齐另一个视图旁边的视图
这里就是我想现在:
UIView *superView = ...;
UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeCustom];
buttonOne.translatesAutoresizingMaskIntoConstraints = NO;
[superView addView:buttonOne];
[buttonOne constrainWidth:@"123" height:HEADER_HEIGHT_STRING];
[buttonOne alignTop:nil leading:nil superView];
UIButton *buttonTwo = [UIButton buttonWithType:UIButtonTypeCustom];
buttonTwo.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:buttonTwo];
[buttonTwo constrainWidth:@"345" height:HEADER_HEIGHT_STRING];
[buttonTwo alignLeadingEdgeWithView:buttonOne predicate:@"123"]
如何避免在代码的最后一行@"123"
?我希望它只使用buttonOne
的宽度。