ConcisePureLayout 被创建出来以便于调用 PureLayout 库 的方法。 (仅支持 Objective-C,Swift 将很快加入。)
pod 'ConcisePureLayout'
依赖关系
ConcisePureLayout 基于第三方 PureLayout 库。因此,PureLayout 将与 ConcisePureLayout 一起安装。
示例代码
UIView * headerView = [UIView newAutoLayoutView];
[headerView setBackgroundColor:[UIColor blackColor]];
[self.view addSubview:headerView];
UIView * footerView = [UIView newAutoLayoutView];
[footerView setBackgroundColor:[UIColor redColor]];
[self.view addSubview:footerView];
// PureLayout implementation
[headerView autoSetDimension:ALDimensionHeight toSize:200];
[headerView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
[headerView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:20];
[headerView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:20];
[footerView autoSetDimension:ALDimensionWidth toSize:250];
[footerView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:headerView withOffset:5];
[footerView autoAlignAxisToSuperviewAxis:ALAxisVertical];
[footerView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
// ConcisePureLayout makes it more concise
[headerView aa_setHeight:200];
[headerView aa_superviewTop:10];
[headerView aa_superviewFitWidthWithInset:20];
[footerView aa_setWidth:250];
[footerView aa_pinUnderView:headerView offset:5];
[footerView aa_centerHorizontal];
[footerView aa_superviewBottom:0];
示例项目
此截图演示了如何使用 ConcisePureLayout 创建和放置复杂的 UI 元素
ConcisePureLayout 仍然非常年轻。并不是所有 PureLayout 的方法都已被简化。剩余方法的简化需要时间和重新思考如何做到更好。让我们共同努力!如果我们能共同创造出既简单又强大的功能,那就太好了。请,Fork & PR!Almas Adilbek 敬上!