🔴Dynamic Type Sizes
DynamicTypeSize+ext (extension)
Human Interface Guidelines ⟩
Dynamic Type Sizes (iOS)
Dynamic Type Sizes (watchOS)
SwiftUI ⟩ State and Data Flow ⟩ EnvironmentValues (struct) ⟩
.dynamicTypeSize : DynamicTypeSize (enum)
.isAccessibilitySize : Bool - case
accessibility1~accessibility5
Examples
例一:顯示各種 dynamic type size 的相對大小。
例二:根據 dynamic type size 將 HStack 調整為 VStack。
struct DynamicTypeSizeView: View {
let sizes = DynamicTypeSize.allCases
var body: some View {
List(sizes, id: \.self){ size in
// ⭐️ custom string interpolation with `LocalizedStringKey`
Text("\(size)")
// ⭐️ dynamic type size (for child views)
.environment(\.dynamicTypeSize, size)
}
}
}
Last updated
Was this helpful?