Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/honghaoz/zhstackview
A simple container view that can hold any UIViews and stack them vertically, you can append, insert and remove a view at any index.It's a kind of simplified UITableView
https://github.com/honghaoz/zhstackview
Last synced: about 1 month ago
JSON representation
A simple container view that can hold any UIViews and stack them vertically, you can append, insert and remove a view at any index.It's a kind of simplified UITableView
- Host: GitHub
- URL: https://github.com/honghaoz/zhstackview
- Owner: honghaoz
- License: mit
- Created: 2014-10-17T16:16:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-25T22:09:23.000Z (about 10 years ago)
- Last Synced: 2023-07-31T15:47:16.577Z (over 1 year ago)
- Language: Swift
- Homepage:
- Size: 3.01 MB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#ZHStackView
ZHStackView is a simple container view that can hold any UIViews and stack them vertically, you can append, insert and remove a view at any index.It's a kind of simplified UITableView.
![](https://raw.githubusercontent.com/honghaoz/ZHStackView/master/Previews/1.png)
## Purpose
We already have UITableView and even more powerful UICollectionView, why do we need this ZHStackView?In some scenarios, like want to show three stacked buttons, a stack of textFields for onboarding view, using tableView is too heavy, I don't want to write too much code for delegation.
What I want is just give me an array of UIViews and I give you well managed containerView.
## Preview:
http://youtu.be/1j6_NHcXKT8http://youtu.be/X-5Ou6Yagds
## Usage
1: Initialize a stackView`var stackedView: ZHStackView = ZHStackView()`
2: Set up views
```
sampleViews = []
for _ in 0 ..< 6 {
sampleViews.append(self.newRandomView())
}
stackedView.setUpViews(sampleViews)
```3: Added stackView on where you want, that's it!
## Advanced Useage
1: You can optionally provide an array of UIEdgeInsets which is a corresponding insets for views and also a containerInset
`stackedView.setUpViews(sampleViews, viewInsets: [UIEdgeInsetsZero, UIEdgeInsetsZero], containerInset: UIEdgeInsetsZero)`
These insets provide a flexiable way for you to layout views on stackView
2: You can set `alignment` for stack view, this property will affect alignment of views
`stackedView.alignment = .Center`
`stackedView.alignment = .Right`
3: There is a property `var defaultSpacing: CGFloat`, this is a easier way to set spacing between views
4: More and more, will implement `orientation` property for horizontal layout.
![](https://raw.githubusercontent.com/honghaoz/ZHStackView/master/Previews/2.png)