Welcome to the documentation for IconFontKit – a library that allows you to efficiently use iconic fonts in your iOS apps. Whether you need to display icons in your user interface or use them for custom graphics, IconFontKit simplifies the process and provides a seamless experience.
Installation
To install IconFontKit in your project, you have multiple options:
- CocoaPods: Add the following line to your Podfile and run
pod install
:
“`ruby
pod ‘IconFontKit’
“`
- Carthage: Add the following line to your Cartfile and run
carthage update
:
“`ruby
github “tobihagemann/IconFontKit”
“`
Don’t forget to import the framework where you need to use it:
“`swift
import IconFontKit
“`
Usage
Overview
IconFontKit provides a unified way to work with popular iconic font collections such as FontAwesome and Ionicons. It exposes a variety of methods and properties to handle icons seamlessly within your app.
Example: FontAwesome
To use FontAwesome icon collection, follow these steps:
- Ensure you have imported IconFontKit into your project.
- Download FontAwesome’s font file (TTF) from the official website or any other reliable source.
- Add the font file to your Xcode project. Make sure to select the target where you want to use it.
- In the project’s Info.plist file, add the font file name (e.g., “FontAwesome.ttf”) to the
UIAppFonts
array. - A namespace class is automatically generated by IconFontKit for each supported iconic font collection. You can access FontAwesome icons using this class.
- Instantiate the FontAwesome namespace class and call the desired icon’s method to get the corresponding Unicode string.
- Use the Unicode string to display the icon in your user interface, as attributed text, or for custom graphics.
“`swift
let fontAwesome = FontAwesome() // Instantiate the namespace class
let iconUnicode = fontAwesome.getIcon(.star) // Get the Unicode string for the star icon
“`
Example: Ionicons
To use the Ionicons collection, you can follow similar steps as mentioned above for FontAwesome. Replace “FontAwesome” with “Ionicons” wherever applicable.
Reference
Supported Fonts
IconFontKit currently supports the following iconic fonts:
- Font1
- Font2
- Font3
Contributing
If you want to contribute to IconFontKit, please follow our guidelines and feel free to submit pull requests. Your contributions are highly appreciated.
That concludes the documentation for IconFontKit. We hope this guide helps you incorporate iconic fonts effortlessly into your iOS apps. Should you have any further questions or encounter any issues, please don’t hesitate to reach out for support.