https://github.com/timoliver/tostackview
A barebones container view for UIKit that stacks collections of subviews
https://github.com/timoliver/tostackview
Last synced: about 1 year ago
JSON representation
A barebones container view for UIKit that stacks collections of subviews
- Host: GitHub
- URL: https://github.com/timoliver/tostackview
- Owner: TimOliver
- License: mit
- Created: 2021-08-28T03:14:52.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-24T08:20:01.000Z (over 2 years ago)
- Last Synced: 2024-05-09T19:58:28.962Z (about 2 years ago)
- Language: Objective-C
- Size: 114 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/TimOliver/TOStackView/actions?query=workflow%3ACI)
[](http://cocoadocs.org/docsets/TOStackView)
[](https://raw.githubusercontent.com/TimOliver/TOStackView/master/LICENSE)
[](http://cocoadocs.org/docsets/TOBorderView)
`TOStackView` is a container view that handles laying out
a collection of subviews in a vertical or horizontal alignment.
It is a very basic version of `UIStackView` that can be used in use cases where the flexibility and complexity of `UIStackView` isn't necessary.
I built this control after I became addicted to the simplicity of `VStack` and `HStack` in SwiftUI, and wanted similar convenience in my UIKit apps, without needing the full complexity of `UIStackView`.
## Features
* Lays out a collection of subviews in a horizontal or vertical alignment.
* Allows for controlling the alignment of the elements on the alternate axis (eg, Left-alignment in vertically stacked elements).
* Provides basic self-sizing functionality.
* Handles baseline alignment of elements that support it, such as SF Symbols images.
## System Requirements
iOS 9.0 and above.
## Installation
**As a CocoaPods Dependency**
Add the following to your Podfile:
```
pod 'TOStackView'
```
**Swift Package Manager**
Will be coming as soon as I get the time! If you can't wait, please consider filing a PR.
**Manual Installation**
Copy the folder `TOStackView` to your Xcode project.
`TOStackView` is an Objective-C project, but it has been written to work properly in Swift as well. If you are using it in a Swift project, don't forget to include it in your Objective-C bridging header.
## Examples
```objc
// Create some content views
UILabel *leftLabel = [[UILabel alloc] init];
leftLabel.text = @"Hello";
[leftLabel sizeToFit];
UILabel *rightLabel = [[UILabel alloc] init];
rightLabel.text = @"Hello";
[rightLabel sizeToFit];
// Create a stack view enclosing the content views
TOStackView *stackView = [[TOStackView alloc] initWithArrangedSubviews:@[leftLabel, rightLabel]];
// Size the stack view to wrap the content views
[stackView sizeToFit];
```
## Credits
`TOStackView` was originally created by [Tim Oliver](http://twitter.com/TimOliverAU) as a component for iComics 2, an upcoming comic reader app for iOS.
iOS Device mockups used in the screenshot created by [Pixeden](http://www.pixeden.com).
## License
`TOStackView` is licensed under the MIT License, please see the [LICENSE](LICENSE) file.