Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasmusson authored Jun 3, 2020
1 parent fc31897 commit e5701a4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions basics/DynamicFont/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ public static var traitTightLeading: UIFontDescriptor.SymbolicTraits { get }
public static var traitLooseLeading: UIFontDescriptor.SymbolicTraits { get }
```

### Customer font
### How to resize a custom font using UIFontMetrics

```swift
tagline.font = UIFontMetrics.default.scaledFont(for: UIFont.systemFont(ofSize: 12, weight: .bold))
if let font = UIFont(name: "Helvetica", size: 72) {
let fontMetrics = UIFontMetrics(forTextStyle: .headline)
label.font = fontMetrics.scaledFont(for: font)
}
```

### Links that help

- [Apple UIFontTextStyle](https://developer.apple.com/documentation/uikit/uifonttextstyle)
- [Bold preferredFont](https://spin.atomicobject.com/2018/02/02/swift-scaled-font-bold-italic/)
- [Paul Hudson Scaled Font](https://www.hackingwithswift.com/example-code/uikit/how-to-resize-a-custom-font-using-uifontmetrics)

0 comments on commit e5701a4

Please sign in to comment.