Skip to content

lacklock/ZHIconFontKit

Repository files navigation

ZHIconFontKit

Language CocoaPods Carthage compatible License

Using icon font in Swift

Requirements

iOS 8.0+

Installation

CocoaPods

To integrate ZHIconFontKit into your Xcode project using CocoaPods, specify it in your Podfile:

  use_frameworks!

  pod ‘ZHIconFontKit’

if you are using swift 2.2:

   pod 'ZHIconFontKit',:git => 'https://github.com/lacklock/ZHIconFontKit.git',:branch => '2.2'

Manual

Just copy the files which under IconFontKit folder to your project

Thaks

FontBlaster

IconFont

#Usage 1.make sure you font has been copy to bundle,check Build Phases: Copy Bundle Resources

2.after import ZHIconFontKit,register icon font:

IconFont.registerIconFontWithName("iconfont")

3.create a enum rawValue type is Int and conform to UnicodeString protocol:

 enum DXYIconFont: Int,UnicodeString{
    case xxx = 59031
    case yyy = 59027
}

UILabel

label.setIconFont(DXYIconFont.xxx, size: 40)

UIButton

button.setTitleIconFont(DXYIconFont.yyy, size: 50)

UIImage

imageView.image = UIImage.iconForIconFont(DXYIconFont.safari, size: 100, color: UIColor.purpleColor(), backgroundColor: UIColor.grayColor(), iconInset: UIEdgeInsets(top: 10, left: 0, bottom: 0, right: 0))

Xib

If you are using in xib,just the same as using a cutom font.After set font as custom font,then paste icon from FontBook in atturibute pannel FontBook

SNS

Weibo : @没故事的卓同学

About

Using icon font in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •