Font Awesome Swift
Follow me: @vaberer
I like ★. Do not forget to ★ this super convenient library.
There is also a very popular Google Design Material Icons library which you will love!
Updated to Swift 2 projects in Swift2 branch
Updated to Font Awesome 4.4 - Added 66 new icons!
Font Awesome swift library for iOS. No image icons any more. Using Font Awesome Swift library is very easy to use. Look at the demo app which shows all icons and their names or just visit FontAwesome.
Requirements
- iOS 8.0+
- Xcode 6.3
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects.
CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:
$ gem install cocoapodsTo integrate Font Awesome Swift into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Font-Awesome-Swift', '~> 1.1.0'Then, run the following command:
$ pod installDo not forget to import to your swift files where you want to use this library:
import Font_Awesome_SwiftTo use Font Awesome in Swift 2:
pod 'Font-Awesome-Swift', :git => 'https://github.com/Vaberer/Font-Awesome-Swift.git', :branch => 'Swift2'
Manually
- Copy
FAIcon.swiftandFontAwesome.ttffiles into your project - Check to import
FontAwesome.ttfin project, "Project" > "Target" > "Copy Bundle Resources"
Cocoa Pods and Master branch will be updated when Swift 2 will not be in beta.
Usage
Super easy way how to add an icon.
UILabel
labelName.FAIcon = FAType.FAGithub
//or if you want to set an icon size, use:
labelName.setFAIcon(FAType.FAGithub, iconSize: 35)
labelName.textColor = UIColor.redColor()UIButton
buttonName.setFAIcon(FAType.FAGithub, forState: .Normal)
//or if you want to set an icon size, use:
buttonName.setFAIcon(FAType.FAGithub, iconSize: 35, forState: .Normal)
buttonName.setTitleColor(UIColor.redColor(), forState: .Normal)UIBarButtonItem
//Standard font size
barName.FAIcon = FAType.FAGithub
//Custom font size
barName.setFAIcon(FAType.FAGithub, iconSize: 35)
barName.tintColor = UIColor.redColor()Author
Patrik Vaberer, patrik.vaberer@gmail.com
Licence
Font Awesome Swift is available under the MIT license. See the LICENSE file for more info.