Reputation: 327
Starting with iOS 15 SwiftUI has a modifier to limit the Dynamic Type size within a view to a given range (when user changes the font size via accessibility):
https://developer.apple.com/documentation/swiftui/view/dynamictypesize(_:)-26aj0
Is there a solution for iOS 13 & 14?
Upvotes: 1
Views: 2650
Reputation: 161
It may be late, but I’ve faced the same problem before and created an extension. You can use it like a dynamicTypeSize modifier.
https://gist.github.com/MMP0/2c1b581ad071c4279806ed5ad995a18a
// iOS 13 - 14
Text("sizeCategory")
.sizeCategory(.large ... .extraExtraExtraLarge)
// iOS 15+
Text("dynamicTypeSize")
.dynamicTypeSize(.large ... .xxxLarge)
Upvotes: 7