Skip to content

Instantly share code, notes, and snippets.

@HarshilShah
Created December 13, 2022 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarshilShah/14bceb365b5e00f6c7f10a6eeb2f06b0 to your computer and use it in GitHub Desktop.
Save HarshilShah/14bceb365b5e00f6c7f10a6eeb2f06b0 to your computer and use it in GitHub Desktop.
Testing the effect of rotation on GeometryReaders
import PlaygroundSupport
import SwiftUI
struct ContentView: View {
@State private var rotation = Angle(degrees: 0)
var body: some View {
VStack {
GeometryReader { proxy in
VStack {
let localFrame = proxy.frame(in: .local)
Text("Local: \(localFrame.size.height, format: .number) × \(localFrame.size.width, format: .number)")
let globalFrame = proxy.frame(in: .global)
Text("Global: \(globalFrame.size.height, format: .number) × \(globalFrame.size.width, format: .number)")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.teal)
}
.rotationEffect(rotation)
Slider(value: $rotation.degrees, in: 0 ... 90)
}
.padding()
}
}
PlaygroundPage.current.setLiveView(
ContentView()
.frame(width: 400, height: 400)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment