iOS 9 introduced the very cool UIStackView, UIStackView can be used to easily create simple and complex layouts.
UIStackView can only be used for iOS9 and up. This project tries to port back the stackview to iOS 6+.
OAStackView aims at replicating all the features in
To run the example project, clone the repo, and run
pod install from the Example directory first.
OAStackView mimics the interface of
UIStackView, the usage of
OAStackView is similar to
OAStackView Can be either used from the Interface builder, or from code.
Drag a a UIView into your view controller, and add some views to it.
Change the class to
(Optional) Change the stack Axis, Spacing, Alignment or distribution.
Run the project!
OAStackView from code, Please refer to UIStackView for propper 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 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)]];
OAStackView is available through CocoaPods. To install it, simply add the following line to your Podfile:
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.
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 improvments
OAStackView implements most of the features from
UIStackView except the following:
@property(nonatomic,getter=isBaselineRelativeArrangement) BOOL baselineRelativeArrangement;
@property(nonatomic,getter=isLayoutMarginsRelativeArrangement) BOOL layoutMarginsRelativeArrangement;
UIStackViewDistribution is also partially implemented (3 elements out of 5 are still not implemented)
- [ ]
- [ ]
- [ ]
Please refer to UIStackView for propper documentation.
The following would be nice to have for future versions
- [ ] Covering the remaining functionality from
- [ ] Better Documentation
- [ ] Better test coverage for come edge cases
- [ ] Rewrite in swift, or more swift friend
Omar Abdelhafith, firstname.lastname@example.org
OAStackView is available under the MIT license. See the LICENSE file for more info.