Skip to content

SwiftUI size reader view modifier to access size of child view

Notifications You must be signed in to change notification settings

vyachesIavskiy/SizeReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

SizeReader

SwiftUI size reader view modifier to access size of child view

Usage

There are two view modifiers that you can use to obtain a size of a view

@State private var size = CGSize.zero

var body: some View {
    ContentView()
        .readSize { newSize
            // newSize will contain a size of a ContentView
        }

    ContentView()
        .readSize($size) // Or you can store it directly in binding
}

About

SwiftUI size reader view modifier to access size of child view

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages