Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hirohisa/Font-Awesome

Use Font Awesome in project written in Swift.
https://github.com/hirohisa/Font-Awesome

List: Font-Awesome

Last synced: about 1 month ago
JSON representation

Use Font Awesome in project written in Swift.

Awesome Lists containing this project

README

        

# Font-Awesome [![license](https://img.shields.io/badge/license-MIT-000000.svg)](https://github.com/hirohisa/Font-Awesome/blob/master/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.

![ ](https://raw.github.com/hirohisa/Font-Awesome/master/Example/Example.png)

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

- [x] Support Unicode from String or Int. not use [UInt](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-ID320)
- [x] Support extension UIButton.
- [x] Support extension UIBarButtonItem
- [x] Support extension UIImageView
- [ ] Support Cocoapods

Usage
----------

1. Set UIFont with size

```swift
let font = UIFont.fontAwesome(size: 40)
```

2. Set String with Unicode

Use String or Int

```swift

extension String {
static func fontAwesome(unicode fontAwesome: UnicodeLiteralConvertible) -> String
}

String.fontAwesome(unicode: 0xf092) // Int
String.fontAwesome(unicode: "f092") // String
```

Example
----------

- Use extension
```swift
// 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).