| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- //
- // UIFont+Extension.swift
- // QuickSearchLocation
- //
- // Created by mac on 2024/4/10.
- //
- import UIKit
- // MARK: - 常用的系统基本字体扩展
- extension UIFont {
-
- // MARK: 1.1、默认字体
- /// 默认字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textF(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .regular)
- }
-
- // MARK: 1.2、常规字体
- /// 常规字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textR(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .regular)
- }
-
- // MARK: 1.3、中等的字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textM(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .medium)
- }
-
- // MARK: 1.4、加粗的字体
- /// 加粗的字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textB(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .bold)
- }
-
- // MARK: 1.5、半粗体的字体
- /// 半粗体的字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textSB(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .semibold)
- }
-
- // MARK: 1.6、超细的字体
- /// 超细的字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textUltraLight(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .ultraLight)
- }
-
- // MARK: 1.7、纤细的字体
- /// 纤细的字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textThin(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .thin)
- }
-
- // MARK: 1.8、亮字体
- /// 亮字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textLight(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .light)
- }
-
- // MARK: 1.9、介于Bold和Black之间
- /// 介于Bold和Black之间
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textHeavy(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .heavy)
- }
-
- // MARK: 1.10、最粗字体
- /// 最粗字体
- /// - Parameter ofSize: 字体大小
- /// - Returns: 字体
- static func textBlack(_ ofSize: CGFloat) -> UIFont {
- return text(ofSize, W: .black)
- }
-
- /// 文字字体
- fileprivate static func text(_ ofSize: CGFloat, W Weight: UIFont.Weight) -> UIFont {
- let scaleSize = ofSize.rpx
- return UIFont.systemFont(ofSize: scaleSize, weight: Weight)
- }
- }
|