Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/99yuseong/spacer
SwiftUI spacer() modifier to add flexible spacing to your views.
https://github.com/99yuseong/spacer
infinity layout maxheight maxwidth spacer swiftui ui
Last synced: 9 days ago
JSON representation
SwiftUI spacer() modifier to add flexible spacing to your views.
- Host: GitHub
- URL: https://github.com/99yuseong/spacer
- Owner: 99yuseong
- License: mit
- Created: 2024-10-30T13:07:27.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-08T04:56:15.000Z (2 months ago)
- Last Synced: 2024-11-08T05:30:35.025Z (2 months ago)
- Topics: infinity, layout, maxheight, maxwidth, spacer, swiftui, ui
- Language: Swift
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spacer
A Swift Package that simplifies layout adjustments by allowing the placement of spacers based on `Edge.Set` positions. This package helps maintain clean, readable code while enhancing layout flexibility in SwiftUI.
## Features
- Place `Spacer` in specific locations (`.leading`, `.trailing`, `.top`, `.bottom`, `.horizontal`, `.vertical` `.all`) with a single modifier.
- Set minimum lengths for each spacer, providing full control over layout gaps.
- Streamline complex layouts while keeping SwiftUI code readable.## Usage
Use `.spacer()` modifier with `Edge.Set` and optional `minLength` to add flexible spacing to your views.
### Ex) Leading Spacer
```swift
Text("Leading Text")
.spacer(.leading)
```### Ex) Trailing Spacer
```swift
Text("Trailing Text")
.spacer(.trailing, minLength: 10)
```### Ex) Spacer for vertical stacks
```swift
import Spacerstruct ContentView: View {
var body: some View {
VStack {
MyLabel("My Label")
.spacer(.trailing)MyButton("My Button") {
print("Button tapped")
}
.spacer(.bottom, minLength: 20)
}
}
}
```## Requirements
- iOS 13.0+
## Installation
### Swift Package Manager
[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
To integrate `Spacer` into your Xcode project using Swift Package Manager, add it to the dependencies value of your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/99yuseong/Spacer.git", .upToNextMajor(from: "1.0.0"))
]
```