Skip to content

hirohisa/Font-Awesome

Repository files navigation

Font-Awesome license

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.

Requirements

  • iOS 7.0+
  • Xcode 6.1

Installation

  1. Copy Font-Awesome directory into your project
  2. Download zip file from https://fortawesome.github.io/Font-Awesome/
  3. Copy FontAwesome.otf from zip file into your project
  4. Check to import FontAwesome.otf in project, "Project" > "Target" > "Copy Bundle Resources"

Features

  • Support Unicode from String or Int. not use UInt
  • Support extension UIButton.
  • Support extension UIBarButtonItem
  • Support extension UIImageView
  • Support Cocoapods

Usage

  1. Set UIFont with size
let font = UIFont.fontAwesome(size: 40)
  1. 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

Example

  • 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")

LICENSE

Font-Awesome is available under the MIT license.

Credit

Font Awesome

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).

About

Use Font Awesome in project written in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published