FontBlaster
所属分类:iPhone/iOS
开发工具:Swift
文件大小:0KB
下载次数:0
上传日期:2023-03-24 14:04:01
上 传 者:
sh-1993
说明: 以编程方式将自定义字体加载到您的iOS、macOS和tvOS应用程序中。
(Programmatically load custom fonts into your iOS, macOS and tvOS app.)
文件列表:
.swiftpm/ (0, 2023-03-24)
.swiftpm/xcode/ (0, 2023-03-24)
.swiftpm/xcode/package.xcworkspace/ (0, 2023-03-24)
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata (135, 2023-03-24)
Example/ (0, 2023-03-24)
Example/.DS_Store (6148, 2023-03-24)
Example/Example.xcodeproj/ (0, 2023-03-24)
Example/Example.xcodeproj/project.pbxproj (21579, 2023-03-24)
Example/Example.xcodeproj/project.xcworkspace/ (0, 2023-03-24)
Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata (207, 2023-03-24)
Example/Example.xcodeproj/project.xcworkspace/xcshareddata/ (0, 2023-03-24)
Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (238, 2023-03-24)
Example/Example.xcworkspace/ (0, 2023-03-24)
Example/Example.xcworkspace/contents.xcworkspacedata (225, 2023-03-24)
Example/Example.xcworkspace/xcshareddata/ (0, 2023-03-24)
Example/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (238, 2023-03-24)
Example/Example/ (0, 2023-03-24)
Example/Example/AppDelegate.swift (464, 2023-03-24)
Example/Example/Base.lproj/ (0, 2023-03-24)
Example/Example/Base.lproj/LaunchScreen.xib (3773, 2023-03-24)
Example/Example/Base.lproj/Main.storyboard (3760, 2023-03-24)
Example/Example/Images.xcassets/ (0, 2023-03-24)
Example/Example/Images.xcassets/AppIcon.appiconset/ (0, 2023-03-24)
Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json (585, 2023-03-24)
Example/Example/Info.plist (1205, 2023-03-24)
Example/Example/TableViewController.swift (1757, 2023-03-24)
Example/OpenSans/ (0, 2023-03-24)
Example/OpenSans/LICENSE.txt (11560, 2023-03-24)
Example/OpenSans/OpenSans-Bold.ttf (224592, 2023-03-24)
Example/OpenSans/OpenSans-BoldItalic.ttf (213292, 2023-03-24)
Example/OpenSans/OpenSans-ExtraBold.ttf (222584, 2023-03-24)
Example/OpenSans/OpenSans-ExtraBoldItalic.ttf (213420, 2023-03-24)
Example/OpenSans/OpenSans-Italic.ttf (212896, 2023-03-24)
Example/OpenSans/OpenSans-Light.ttf (222412, 2023-03-24)
Example/OpenSans/OpenSans-LightItalic.ttf (213128, 2023-03-24)
Example/OpenSans/OpenSans-Regular.ttf (217360, 2023-03-24)
Example/OpenSans/OpenSans-Semibold.ttf (221328, 2023-03-24)
Example/OpenSans/OpenSans-SemiboldItalic.ttf (212820, 2023-03-24)
Example/Podfile (121, 2023-03-24)
... ...
# FontBlaster
### Programmatically load custom fonts into your iOS, macOS, and tvOS app.
![Swift Support](https://img.shields.io/badge/Swift-5.3-orange.svg) ![Platform](https://img.shields.io/badge/Platforms-iOS%20%7c%20macOS%20%7c%20tvOS%20-lightgray.svg?style=flat) [![CocoaPods](https://img.shields.io/cocoapods/v/FontBlaster.svg)](https://cocoapods.org/pods/FontBlaster) [![SwiftPM Compatible](https://img.shields.io/badge/SwiftPM-Compatible-brightgreen.svg)](https://swift.org/package-manager/)
---
## About
Say goodbye to importing custom fonts via property lists as **FontBlaster** automatically imports and loads all fonts in your app's Bundles with one line of code.
## Features
- [x] CocoaPods Support
- [x] Swift PM Support
- [x] Automatically imports fonts from `Bundle.main`
- [x] Able to import fonts from remote bundles
- [x] Sample Project
## Installation Instructions
| Swift Version | Branch Name | Will Continue to Receive Updates?
| ------------- | ------------- | -------------
| 5.1+ | master | **Yes**
| 5.0 | swift5.0 | No
| 4.2 | swift4.2 | No
| 4.1 | swift4.1 | No
| 3.2 | swift3.2 | No
| 3.1 | swift3.1 | No
### CocoaPods
```ruby
pod 'FontBlaster' # Swift 5.1+
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift5.0' # Swift 5.0
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift4.2' # Swift 4.2
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift4.1' # Swift 4.1
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift3.2' # Swift 3.2
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift3.2' # Swift 3.1
```
### Swift Package Manager
``` swift
.Package(url: "https://github.com/ArtSabintsev/FontBlaster.git", majorVersion: 4)
```
### Manual
1. [Download FontBlaster](//github.com/ArtSabintsev/FontBlaster/archive/master.zip).
2. Copy `FontBlaster.swift` into your project.
## Setup
Typically, all fonts are automatically found in `Bundle.main`. Even if you have a custom bundle, it's usually lodged inside of the `mainBundle.` Therefore, to load all the fonts in your application, irrespective of the bundle it's in, simply call:
```Swift
FontBlaster.blast() // Defaults to Bundle.main if no arguments are passed
```
If you are loading from a bundle that isn't found inside your app's `mainBundle`, simply pass a reference to your `Bundle` in the `blast(_:)` method:
```Swift
FontBlaster.blast(bundle:) // Takes one argument of type Bundle, or as mentioned above, defaults to Bundle.main if no arguments are passed
```
If you need a list of all of the loaded fonts, an overloaded version of the `blast(_:)` method has a completion handler that returns just that. Just like the original method, this method takes either a custom `Bundle` or defaults to `Bundle.main` if no argument is passed.
```Swift
// Defaults to Bundle.main as no argument is passed
FontBlaster.blast() { (fonts) in
print(fonts) // fonts is an array of Strings containing font names
}
// Custom bundle is passed as argument
FontBlaster.blast(bundle:) { (fonts) in
print(fonts) // fonts is an array of Strings containing font names
}
```
To turn on console debug statements, simply set `debugEnabled() = true` **before** calling either `blast()` method:
```Swift
FontBlaster.debugEnabled = true
FontBlaster.blast()
```
## Sample Project
A Sample iOS project is included in the repo. When you launch the app, all fonts are configured to load custom fonts, but don't actually display them *until* you push the button on the navigation bar. After pushing the button, **FontBlaster** imports your fonts and redraws the view.
## Inspiration
This project builds upon an old solution that [Marco Arment](http://twitter.com/marcoarment) proposed and wrote about on his [blog](http://www.marco.org/2012/12/21/ios-dynamic-font-loading).
## Created and maintained by
[Arthur Ariel Sabintsev](http://www.sabintsev.com/)
近期下载者:
相关文件:
收藏者: