-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- preferred font를 확장하여 bold, italic을 손쉽게 적용할 수 있도록 extension 마련
- Loading branch information
Showing
2 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
iOS/Projects/Shared/DesignSystem/Sources/UIFont+preferredFont.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// UIFont+preferredFont.swift | ||
// DesignSystem | ||
// | ||
// Created by 홍승현 on 11/14/23. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIFont { | ||
static func preferredFont(forTextStyle: TextStyle, with traits: UIFontDescriptor.SymbolicTraits) -> UIFont { | ||
let font = Self.preferredFont(forTextStyle: forTextStyle) | ||
guard let descriptor = font.fontDescriptor.withSymbolicTraits(traits) else { | ||
return font | ||
} | ||
|
||
return UIFont(descriptor: descriptor, size: 0) | ||
} | ||
} |