Git Product home page Git Product logo

oastackview's Introduction

OAStackView

Build Status Version License Platform

iOS 9 introduced the very cool UIStackView, UIStackView can be used to easily create simple and complex layouts.

As expected UIStackView can only be used for iOS 9 and up. This project tries to port back the stackview to iOS 7+.

OAStackView aims at replicating all the features in UIStackView

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Since OAStackView mimics the interface of UIStackView, the usage of OAStackView is similar to UIStackView.

OAStackView Can be either used from the Interface builder, or from code.

Interface Builder

Drag a a UIView into your view controller, and add some views to it.

 photo step1_zps2xxl75vw.png

Change the class to OAStackView

 photo step2_zpsfgwirklz.png

(Optional) Change the stack Axis (set Axis Value to 0 for Horizontal or 1 for Vertical), Spacing, Alignment or distribution.

 photo step3_zpsmk8xw3hz.png

Run the project!

 photo step4_zpsgl92oeoc.png

From Code

To use OAStackView from code, Please refer to UIStackView for proper documentation.

As a quick example on its usage do the following:

Create a couple of views to be stacked:

 UILabel *l1 = [[UILabel alloc] init];
 l1.text = @"Label 1";
 UILabel *l2 = [[UILabel alloc] init];
 l2.text = @"Label 2";

Create the stack view passing the array of views:

OAStackView *stackView = [[OAStackView alloc] initWithArrangedSubviews:@[l1, l2]];
stackView.translatesAutoresizingMaskIntoConstraints = NO;

Add the stack view to self.view

[self.view addSubview:stackView];

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-30-[stackView]"
                                                                  options:0
                                                                  metrics:0
                                                                    views:NSDictionaryOfVariableBindings(stackView)]];

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[stackView]"
                                                                  options:0
                                                                  metrics:0
                                                                    views:NSDictionaryOfVariableBindings(stackView)]];

Installation

OAStackView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "OAStackView"

Tests

Since OAStackView has been built from reverse engineering UIStackView, and since I intend to keep updating and refactoring OAStackView, tests was one of the requirements going forward.

The following a human readable text subscript (generated with specipy).

Contribution

All contributions in any form are welcomed, if you find the project helpful, and you want to contribute then please do.

Known Issues, and future improvements

Missing functionality

OAStackView implements most of the features from UIStackView except the following:

  • baselineRelativeArrangement

    @property(nonatomic,getter=isBaselineRelativeArrangement) BOOL baselineRelativeArrangement;

  • layoutMarginsRelativeArrangement

    @property(nonatomic,getter=isLayoutMarginsRelativeArrangement) BOOL layoutMarginsRelativeArrangement;

UIStackViewDistribution is also partially implemented (2 elements out of 5 are still not implemented)

  • UIStackViewDistributionFill
  • UIStackViewDistributionFillEqually
  • UIStackViewDistributionFillProportionally
  • UIStackViewDistributionEqualSpacing
  • UIStackViewDistributionEqualCentering

Please refer to UIStackView for proper documentation.

Future improvements

The following would be nice to have for future versions

  • Covering the remaining functionality from UIStackView
  • Better Documentation
  • Better test coverage for some edge cases
  • Rewrite in swift, or more swift friendly

Author

Omar Abdelhafith, [email protected]

License

OAStackView is available under the MIT license. See the LICENSE file for more info.

oastackview's People

Contributors

algal avatar assafgelber avatar ay8s avatar bartvandendriessche avatar cabeca avatar calebd avatar delebedev avatar harlanhaskins avatar izackp avatar jamieq avatar jstart avatar m1entus avatar mattiasjahnke-pp avatar neilbilly avatar nsomar avatar pizthewiz avatar skywinder avatar thomvis avatar yusefnapora avatar zeveisenberg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.