-
-
Save HarshilShah/14bceb365b5e00f6c7f10a6eeb2f06b0 to your computer and use it in GitHub Desktop.
Testing the effect of rotation on GeometryReaders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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