• Stars
    star
    2,141
  • Rank 21,556 (Top 0.5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Porting UIStackView to iOS 7+

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.

More Repositories

1

Swiftline

Swiftline is a set of tools to help you create command line applications.
Swift
1,197
star
2

Guaka

The smartest and most beautiful (POSIX compliant) Command line framework for Swift 🤖
Swift
1,146
star
3

Download-Manager

iOS download manager, Download a set of files in parallel and sequential order.
Objective-C
196
star
4

mockpy

Mockpy is an open source tool to quickly create mock servers.
Python
138
star
5

OALayoutAnchor

Porting NSLayoutAnchor to iOS7 (full port)
Objective-C
83
star
6

Collection-Each

Adding ruby style each iterator to Cocoa/Cocoa touch Swift Array and Range classes, And Int.times{} to Int class
Swift
65
star
7

facebook_messenger

ExFacebookMessenger is a library that helps you create facebook messenger bots easily.
Elixir
58
star
8

OAStatusItemKit

OAStatusItemKit allows you to easily create mac status bar apps with a swifty flavour.
Swift
34
star
9

github-project-landing-page

A Github project landing page theme for Hugo.
HTML
27
star
10

exrequester

Quickly create API clients using module attributes.
Elixir
19
star
11

phoenix_facebook_echo_bot

Elixir sample facebook messenger echo bot using Phoenix framework.
Elixir
19
star
12

RangeSliderView

RangeSliderView provide an easy to use range selection view.
Swift
18
star
13

zenixir

Elixir Zendesk API Client http://developer.zendesk.com/
Elixir
17
star
14

ipa_utilities

Simple ruby gem to execute common ipa utilities, such as verify integrity, convert certificate formats, re-signs an ipa using a new provision profile and more.
Ruby
17
star
15

xserverpy

Manage Xcode server bots from the command line, without the need to open or install Xcode.
Python
16
star
16

dtracer

DTracer is part ruby gem, part iOS pod, that helps the sending and receiving of DTrace commands.
Ruby
14
star
17

IAModelBase

Json (and NSDictionary) to Objective c Model Helper
Objective-C
14
star
18

CodeImager

Generate a beautiful image from a code snippet on Mac OS.
11
star
19

phoenix_facebook_messenger

PhoenixFacebookMessenger is a library that helps you create facebook messenger bots easily with phoenix.
Elixir
10
star
20

Suas-iOS

Unidirectional data flow architecture implementation for iOS, macOS, tvOS and watchOS
Swift
8
star
21

JavaErlang

Java Erlang Integration using JInterface (OtpErlang)
Java
8
star
22

IASequenceAnimations

Perform a sequence of animations one after the other using blocks
Objective-C
8
star
23

ex_stub

ExStub provides an easy way to stub a module and record the function calls on it.
Elixir
8
star
24

OADTracer

Objective c library that facilitates the sending of DTrace commands.
Objective-C
8
star
25

Sublime-Text-Midnight

Sublime Text Midnight Theme (ported from Xcode Midnight theme)
7
star
26

IADraggableViewController

Create an apple iOS5 camera like View Controllers container
Objective-C
7
star
27

specipy

Extract spec descriptions from Kiwi
Python
7
star
28

StringScanner

A string scanner (similar to NSScanner) implementation purely implemented in swift written in swift
Swift
6
star
29

Storyboard_Layout_Translator

Storyboard Layout Translator
Ruby
5
star
30

profiles

A gem that searches local provision profiles and an ipa for a UDID
Ruby
4
star
31

IAAnimationTable

Fun with UITableView
Objective-C
4
star
32

RandomUser

Objective c iOS library for to generate random users, using https://randomuser.me/
Objective-C
3
star
33

Guaka-Generator

Guaka command line application generator app.
Swift
3
star
34

EmojiOntology

Emoji ontology project for UCD
Web Ontology Language
3
star
35

Currying-refresh-token

A swift playground containing samples on how to use swift functional currying
Swift
2
star
36

ObjcAndSwift

Objective-C and Swift in the same Dynamic Framework Target
Objective-C
2
star
37

Suas-Monitor

Cross-platform desktop app for visualizing and debugging apps built with Suas
TypeScript
1
star
38

TestTrunk

Ruby
1
star
39

Environ

Environ is a library that wrap libc environ to get all the environment variables passed to an application
Swift
1
star
40

LeftPad

Swift implementation of the famous npm left-pad (http://left-pad.io/) module
Ruby
1
star
41

homebrew-tap

Homebrew tap for mockpy
Ruby
1
star
42

elixir-algos

Some algorithm solutions in Elixir
Elixir
1
star
43

Swift-type-erasure-playground

Swift Type erasure playground
Swift
1
star