iOS UIStackView

开篇两个参考:

  1.https://www.jianshu.com/p/8270db45cfa1

  2.https://spin.atomicobject.com/2016/06/22/uistackview-distribution/

 

 

实现的场景是由任意个View需要添加到这个容器里面,然后整体左对齐,也就是一次从左往右排,并且不会被拉伸。实现的方式也很简单:】

    [imageEvaluateRED setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

 使用上面设置禁止拉伸,然后再在最后的arrangeView里面增加一个空白的View来填充剩下的内容

    UIView* spaceView = [[UIView alloc] init];
    [self.evaluateStackView addArrangedSubview:imageEvaluateRED];
    [self.evaluateStackView addArrangedSubview:imageEvaluateYELLOW];
    [self.evaluateStackView addArrangedSubview:imageEvaluateGREEN];
    [self.evaluateStackView addArrangedSubview:spaceView];

 这样再配合 Space = 10 就能完成适配

 

 

转载于:https://www.cnblogs.com/JMarshall/p/11532352.html

你可能感兴趣的:(iOS UIStackView)