Last active
November 23, 2022 16:23
-
-
Save aerialcombat/a730c4c8fd4f12cb11716560ee808bc7 to your computer and use it in GitHub Desktop.
UIFont extension for scaling fonts with UIFontMetrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIFont+Extensions.swift | |
// | |
// UIFont extension for scaling fonts with UIFontMetrics | |
// | |
import UIKit | |
extension UIFont { | |
func scaledFont(forTextStyle textStyle: UIFont.TextStyle) -> UIFont { | |
return UIFontMetrics(forTextStyle: textStyle).scaledFont(for: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
refer to: https://www.hackingwithswift.com/example-code/uikit/how-to-resize-a-custom-font-using-uifontmetrics