History
Loading...
Loading...
August 28, 2025
@ScaledMetric to scale custom spacing and dimensions based on the user's Dynamic Type setting. Simply add @ScaledMetric private var padding: CGFloat = 16 and your custom padding will automatically adjust when users change their text size preferences.Semantic font styles like `.title2`, `.headline`, and `.body` automatically adapt to the user's preferred text size settings, ensuring your app remains readable for users with visual impairments or those who simply prefer larger text.
// ❌ Avoid fixed font sizes
Text("Welcome")
.font(.system(size: 24, weight: .bold))
// ✅ Use semantic font styles
Text("Welcome")
.font(.title2.bold())
// ✅ For custom fonts, maintain Dynamic Type support
Text("Custom Brand Text")
.font(.custom("YourFont-Bold", size: 18, relativeTo: .title2))Fixed font sizes ignore accessibility settings and can make your app unusable for millions of users. Semantic styles respect system settings while maintaining your design hierarchy, and using `relativeTo` with custom fonts ensures they scale proportionally with the user's preferences.