Skip to content

Instantly share code, notes, and snippets.

@garsdle
garsdle / View+Relative.swift
Last active July 27, 2021 22:40 — forked from IanKeen/View+Relative.swift
SwiftUI relative frame
struct SizePreferenceKey: PreferenceKey {
static var defaultValue: CGSize = .zero
static func reduce(value: inout CGSize, nextValue: () -> CGSize) {
value = nextValue()
}
}
struct RelativeSizeModifier: ViewModifier {
let percentWidth: CGFloat