CSLinearLayoutView

来源:互联网 发布:家庭千兆网络布置 编辑:程序博客网 时间:2024/05/22 11:35

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.

CSLinearLayoutView Screenshots

Example Usage

// create the linear layout viewCSLinearLayoutView *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 displayCSLinearLayoutItem *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

  1. Add CSLinearLayoutView.h & CSLinearLayoutView.m to your project.
  2. If you're using ARC, you'll need to add the -fno-objc-arc compiler flag to CSLinearLayoutView.m.