Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MwaiBanda authored Jun 22, 2024
1 parent 85c16af commit 7f7c8b3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,24 @@ val font: Font = MR.fonts.Raleway.italic.asFont(
style = FontStyle.Normal // optional
)
```
#### SwiftUI

For SwiftUI, create this `Font` extension:

```swift
extension Font {
init(resource: KeyPath<MR.fonts, FontResource>, withSize: Double = 14.0) {
self.init(MR.fonts()[keyPath: resource].uiFont(withSize: withSize))
}
}
```

Then, you can refer to `FontResource`s directly by their key path, which provides compiler errors for typos or missing resources:

```swift
Text("Text displayed resource font")
.font(Font(resource: \.raleway_regular, withSize: 14.0))
```

### Example 9 - pass colors

Expand Down

1 comment on commit 7f7c8b3

@the-best-is-best
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for support

Please sign in to comment.