https://github.com/scalessec/CSLinearLayoutView
CSLinearLayoutView
CSLinearLayoutView
is designed to simplify relative layouts on iOS.
We've all been there before— the content in your app is dynamic and you need to display different sized views in neat succession. You spend the next hours pushing pixels, estimating text sizes, and tracking deltas. Lame.
Enter CSLinearLayoutView
. Create your layout view, create layout items with the views you want to display, and then add the items to your layout. Much simpler.
Example Usage
// create the linear layout view
CSLinearLayoutView *linearLayoutView = [[[CSLinearLayoutView alloc] initWithFrame:self.view.bounds] autorelease];
linearLayoutView.orientation = CSLinearLayoutViewOrientationVertical;
[self.view addSubview:linearLayoutView];
// create a layout item for the view you want to display
CSLinearLayoutItem *item = [CSLinearLayoutItem layoutItemForView:someView];
item.padding = CSLinearLayoutMakePadding(5.0, 10.0, 5.0, 10.0);
item.horizontalAlignment = CSLinearLayoutItemHorizontalAlignmentCenter;
item.fillMode = CSLinearLayoutItemFillModeNormal;
// add the layout item to the linear layout view
[linearLayoutView addItem:item];
Checkout the demo project for additional tests and examples.
Setup Instructions
- Add
CSLinearLayoutView.h
&CSLinearLayoutView.m
to your project. - If you're using ARC, you'll need to add the
-fno-objc-arc
compiler flag toCSLinearLayoutView.m
.