Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created May 30, 2022 21:52
Show Gist options
  • Save sturdysturge/979b35db7cd6504c7f7f5b54659dfd6f to your computer and use it in GitHub Desktop.
Save sturdysturge/979b35db7cd6504c7f7f5b54659dfd6f to your computer and use it in GitHub Desktop.
import SwiftUI
struct ScaledPaddingView: View {
var body: some View {
GeometryReader { geometry in
let frame = geometry.frame(in: .local)
Rectangle()
.foregroundColor(.red)
.padding(.horizontal, frame.maxX * 0.2)
.padding(.vertical, frame.maxY * 0.2)
.background(Color.green)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment