Use Font Awesome in project written in Swift. If you hope to use lastest edition, it is possible by Font-Awesome
.
Font-Awesome
supports the input with Unicode.
- iOS 7.0+
- Xcode 6.1
- Copy
Font-Awesome
directory into your project - Download zip file from https://fortawesome.github.io/Font-Awesome/
- Copy
FontAwesome.otf
from zip file into your project - Check to import
FontAwesome.otf
in project, "Project" > "Target" > "Copy Bundle Resources"
- Support Unicode from String or Int. not use UInt
- Support extension UIButton.
- Support extension UIBarButtonItem
- Support extension UIImageView
- Support Cocoapods
- Set UIFont with size
let font = UIFont.fontAwesome(size: 40)
- Set String with Unicode
Use String or Int
extension String {
static func fontAwesome(unicode fontAwesome: UnicodeLiteralConvertible) -> String
}
String.fontAwesome(unicode: 0xf092) // Int
String.fontAwesome(unicode: "f092") // String
- Use extension
// UIButton
let button = UIButton(frame: frame)
button.setTitleColor(UIColor.blueColor(), forState: .Normal)
button.setFontAwesome(fontAwesome: "f081", forState: .Normal)
// UIBarButtonItem
let barButtonItem = UIBarButtonItem(fontAwesome: "f002", target: nil, action: nil) // f002 = fa-search
navigationItem.rightBarButtonItem = barButtonItem
// UILabel
let label = UILabel(frame: frame)
label.font = UIFont.fontAwesome(size: 40)
label.text = String.fontAwesome(unicode: 0xf092) // f092 = fa-github-square
// UIImageView
let imageView = UIImageView(frame: frame)
imageView.fontAwesome(fontAwesome: "f087")
Font-Awesome is available under the MIT license.
The Font Awesome webfont, CSS, and LESS files are licensed under CC BY 3.0. A mention of Font Awesome - http://fortawesome.github.com/Font-Awesome in human-readable source code is considered acceptable attribution (most common on the web). If human readable source code is not available to the end user, a mention in an 'About' or 'Credits' screen is considered acceptable (most common in desktop or mobile software).