Skip to content

heestand-xyz/GeometryWriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUI GeometryWriter

The GeometryWriter writes the minimum frame to a View.

It is the opposite of a GeometryReader, as in that the GeometryReader will take up as much space as possible and the GeometryWriter will take up as little space as possible, constraining a view to it's visible frame. Any area with opacity 0.0 will be cropped.

The blue border is the resulting frame of a view in a GeometryWriter.

Code Example

import SwiftUI
import GeometryWriter

struct ContentView: View {
    
    @State private var active: Bool = false
    
    var body: some View {
        
        GeometryWriter { _ in
            
            Toggle(isOn: $active) {
                EmptyView()
            }
        }
        .border(.blue)
    }
}

Swift Package

.package(url: "https://github.com/heestand-xyz/GeometryWriter", from: "1.0.0")

Minimum requirement: iOS 14

About

The opposite of a GeometryReader in SwiftUI

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages