Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattmaddux/faswiftui
Easy Font Awesome in SwiftUI
https://github.com/mattmaddux/faswiftui
font-awesome swift swiftui
Last synced: about 2 months ago
JSON representation
Easy Font Awesome in SwiftUI
- Host: GitHub
- URL: https://github.com/mattmaddux/faswiftui
- Owner: mattmaddux
- License: mit
- Created: 2019-10-04T20:09:23.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-07T15:34:02.000Z (about 1 year ago)
- Last Synced: 2023-10-07T16:30:05.767Z (about 1 year ago)
- Topics: font-awesome, swift, swiftui
- Language: Swift
- Homepage:
- Size: 210 KB
- Stars: 75
- Watchers: 3
- Forks: 20
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FASwiftUI
Easily integrate FontAwesome 5 or 6 into your SwiftUI projects. Use Font Awesome icons as text in your SwiftUI views. Supports Font Awesome Pro or Free.
(Does not currently support the Duotone style.)
### Installation - Swift Package Manager
----------------------------------
1. Add the Swift package to your Xcode project
1. File -> Swift Packages -> Add Package Dependency
2. Enter https://github.com/mattmaddux/FASwiftUI.git
2. Download Font Awesome
1. Go to https://fontawesome.com/download
2. Download the Pro or Free version
3. Drag the following files from the download to your project:
* icons.json
AND EITHER
* Font Awesome 6 Brands-Regular-400.otf
* Font Awesome 6 [Free/Pro/Sharp]-Regular-400.otf
* Font Awesome 6 [Free/Pro/Sharp]-Solid-900.otf
* Font Awesome 6 [Pro/Sharp]-Light-300.otf (Pro Only)
OR
* Font Awesome 5 Brands-Regular-400.otf
* Font Awesome 5 [Free/Pro]-Regular-400.otf
* Font Awesome 5 [Free/Pro]-Solid-900.otf
* Font Awesome 5 Pro-Light-300.otf (Pro Only)
4. Add files to target - For each of the files in the last step:
1. Select the file in Project Navigator
2. Open the Inspectors bar on the right and select the file inspector (first tab)
3. Under Target Membership select each target you need to use FASwiftUI
5. Add Fonts to Info.plist
1. Open your project's info.plist
2. Right-Click in a blank area and choose "Add Row"
3. Name the new entry "Fonts provided by application"
4. Expand the entry by clicking the triangle to the left
5. Add a new entry for each of the "otf" files you added to your project, using the full filename including the extension
6. You're done!### Usage
----------------------------------
Use a Font Awesome icon in any view:
```swift
import SwiftUI
import FASwiftUIstruct ContentView: View {
var body: some View {
FAText(iconName: "bomb", size: 200)
}
}
```![Regualr Icon Screenshot](https://raw.githubusercontent.com/mattmaddux/FASwiftUI/master/icon-regular.png)
You can also choose an alternate style.
(This is ignored if the icon is a brand and currently duotone is not supported and will default back to regular.)```swift
import SwiftUI
import FASwiftUIstruct ContentView: View {
var body: some View {
FAText(iconName: "bomb", size: 200, style: .solid)
}
}
```![Regualr Icon Screenshot](https://raw.githubusercontent.com/mattmaddux/FASwiftUI/master/icon-fill.png)
Set the color as you would any text.
```swift
import SwiftUI
import FASwiftUIstruct ContentView: View {
var body: some View {
FAText(iconName: "bomb", size: 200)
.foregroundColor(Color.red)
}
}
```![Regualr Icon Screenshot](https://raw.githubusercontent.com/mattmaddux/FASwiftUI/master/icon-red.png)