antife-yinyue / Iconfont.swift

Enable iconfont for your swift projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Iconfont.swift

Build status Carthage compatible

Requirements

  • iOS 7.0
  • Xcode 7.2 (Swift 2.1)

Installation

Using Carthage

Add github "jsw0528/Iconfont.swift" to your Cartfile and run carthage update --platform iOS. If unfamiliar with Carthage then checkout their Getting Started section or this sample app

Then add import Iconfont to the top of the files using Iconfont.swift.

Usage

// Register
UIFont.register("Assets/Fonts/FontAwesome.otf")

// Working with UILabel
let label = UILabel(frame: CGRectMake(100, 100, 100, 100))
label.font = UIFont(name: "FontAwesome", size: 100)
label.text = "\u{f09b}" // Unicode

// Working with UIButton
let btn = UIButton(frame: CGRectMake(100, 300, 100, 40))
btn.titleLabel!.font = UIFont(name: "FontAwesome", size: 40)
btn.setTitle("\u{f09b}", forState: .Normal)
btn.setTitleColor(UIColor.blackColor(), forState: .Normal)

// Working with UIImage
let img = UIImage.iconfont("\u{f09b}", familyName: "FontAwesome", size: 100)
let imgView = UIImageView()
imgView.image = img
imgView.frame = CGRectMake(100, 400, img.size.width, img.size.height)

License

Iconfont.swift is released under an MIT license. See the LICENSE file for more information.

About

Enable iconfont for your swift projects.

License:MIT License


Languages

Language:Swift 88.0%Language:Objective-C 9.3%Language:Makefile 2.7%