-
Notifications
You must be signed in to change notification settings - Fork 31
GeometryReaders
Nick Sarno edited this page Apr 11, 2022
·
3 revisions
Adds a transparent View and read its frame.
FrameReader(coordinateSpace: .global) { frame in
let minX = frame.minX
let minY = frame.minY
let maxX = frame.maxX
let maxY = frame.maxY
let width = frame.width
let height = frame.height
}
Get the frame of a View.
Text("Hello, world!")
.readingFrame { frame in
}
Use LocationReader if you only need a CGPoint. This limits the new View's frame to .frame(width: 0, height: 0).
LocationReader { location in
let xPosition = location.x
let yPostition = location.y
}
Get the center point of a View.
Text("Hello, world!")
.readingLocation { location in
}