Created
January 18, 2021 14:35
-
-
Save mohsinbmwm3/f6fb4cd82e7ad33cf65a0dc2f24a309f to your computer and use it in GitHub Desktop.
Some custom font swift extension ideas.
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
import UIKit | |
// Its better to create custom font name as constant to avoid spelling mistakes when using this. | |
extension String { | |
static let appCustomFontRegular = "Montserrat" | |
static let appCustomFontBold = "Montserrat-Bold" | |
} | |
extension UIFont { | |
static func appRegularFont(size: CGFloat) -> UIFont { | |
return UIFont(name: String.appCustomFontRegular, size: size) ?? .systemFont(ofSize: size) | |
} | |
static func appBoldFont(size: CGFloat) -> UIFont { | |
return UIFont(name: String.appCustomFontBold, size: size) ?? .boldSystemFont(ofSize: size) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment