Home > AI > IOS > SwiftUI >

@ScaledMetric

Example: it is connected with Dynamic Type settings to see the effect.

struct ContentView: View {
    @ScaledMetric(relativeTo: .body) var spacing: CGFloat = 8

    var body: some View {
        VStack(spacing: spacing) {
            ForEach(0...10, id: \.self) { number in
                Text(String(number))
            }
        }
    }
}

Leave a Reply