Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon)

Overview

SwiftIconFont Banner

Build Status Version License Platform Carthage compatible Reviewed by Hound

Installation

SPM

Not yet supported. Please use Cocoapods or Carthage

Carthage

github "0x73/SwiftIconFont"

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

You can install it with the following command:

$ gem install cocoapods

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

use_frameworks!

pod 'SwiftIconFont'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Prefixes

Font Prefix Cheat Sheet
Font Awesome 5 fa5: List
Font Awesome 5 Brand fa5b: List
Font Awesome 5 Solid fa5s: List
Ion Icons io: List
Octicons oc: List
Open Iconic ic: List
Material Icon ma: List
Themify ti: List
Map Icons mi: List
Segoe MDL2 sm: List
Foundation 3 fo: List
Elegant Icon el: List
Captain cp: Please check example project.

Fonts

public enum Fonts: String {
    case fontAwesome5 = "FontAwesome5Free-Regular"
    case fontAwesome5Brand = "FontAwesome5Brands-Regular"
    case fontAwesome5Solid = "FontAwesome5Free-Solid"
    case iconic = "open-iconic"
    case ionicon = "Ionicons"
    case octicon = "octicons"
    case themify = "themify"
    case mapIcon = "map-icons"
    case materialIcon = "MaterialIcons-Regular"
    case segoeMDL2 = "Segoe mdl2 assets"
    case foundation = "fontcustom"
    case elegantIcon = "ElegantIcons"
    case captain = "captainicon"
}

Storyboard

SwiftIconFont Banner

Runtime Structure

< Prefix >:< Icon >

Usage

In your UILabel, UIButton or UITextField, set a text containing a placeholder anywhere you want the icon to be. Somethink like this

oc:logo-github

Then you can choose between 3 ways you can use SwiftIconFont.

1. Without Custom Class

Simply import SwiftIconFont and call processIcons on any UILabel, UIButton or UITextField that has a placeholder.

label.parseIcon()

2. Custom Class

The lazy way, just set your UILabel, UITextField, UIButton, UITextView, UIBarButtonItem class as SwiftIconLabel, SwiftIconTextField, SwiftIconButton, SwiftIconTextView, SwiftBarButtonItem, and thats it, your icons will be processed at runtime.

3. Programmatically

import SwiftIconFont

label.font = UIFont.icon(from: .fontAwesome5, ofSize: 50.0)
label.text = String.fontAwesome5Icon(code: "twitter")

UIBarButtonItem (Without Custom Class)

import SwiftIconFont

twitterBarButton.icon(from: .fontAwesome5, code: "twitter", ofSize: 20)

UITabBarItem (Without Custom Class)

import SwiftIconFont

twitterTabBarButton.icon(from: .fontAwesome5, code: "twitter", imageSize: CGSizeMake(20, 20), ofSize: 20)

UIImage

import SwiftIconFont

let githubLogo = UIImage(from: .octicon, code: "logo-github", textColor: .black, backgroundColor: .clear, size: CGSize(width: 150, height: 50))

UIImageView

import SwiftIconFont

let githubLogoImageView: UIImageView = UIImageView(frame: CGRect(x: 120, y: self.view.frame.size.height - 130, width: 150, height: 50))
githubLogoImageView.setIcon(from: .octicon, code: "logo-github", textColor: .black, backgroundColor: .clear, size: nil)

macOS

  • NSTextField, NSImage, NSView
  • Please check ExampleMac project

Author

Sedat ÇİFTÇİ - [email protected]

Contributors

josejuanqm

License

SwiftIconFont is available under the MIT license. See the LICENSE file for more info.

Contributing

  1. Fork it (http://github.com/0x73/SwiftIconFont/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Comments
  • Adding UIImage extension to create images out of icons.  refactor UIT…

    Adding UIImage extension to create images out of icons. refactor UIT…

    This is a simple refactor of code you already had written for UITabBarItem. It exposes that method to a UIImage Category so it is more reusable.

    This should be updated to add more features like a background color or something like that later.

    opened by jacobbullock 5
  • parseIcon works only with FontAwesome

    parseIcon works only with FontAwesome

    Hi, Love this framework but I seem to have a problem with parseIcon, as it works only with fa:* I tried all other sources but non of them works.

    I am working with Xcode 8 running iOS target 9.0, the device it self has iOS 10

    Thanks.

    opened by shshalom 3
  • MapIcon & MaterialIcon

    MapIcon & MaterialIcon

    SwiftIconFont Version

    6.1.0

    Steps to Reproduce

    1. With SwiftIconFont installed, visit the Material Design Icons library or Map Icons library
    2. Copy the name of an icon that contains an underscore (ie. accessibility_new)
    3. Paste the copied name to use as a code (ie. UIImage(from:code:textColor:backgroundColor:size:) Such as:
    UIImage(from: .materialIcon,
            code: "accessibility_new", // <--
            textColor: .black,
            backgroundColor: .clear,
            size: CGSize(width: 50, height: 50))
    

    Expected behavior

    Material Design Icon for accessibility_new correctly displays as a UIImage

    Actual Behavior

    Runtime failure Thread 1: Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value

    Workaround

    When using MaterialIcon or MapIcon, replace any _ with . ie. change from: accessibility_new to accessibility.new

    Possible Fix 1

    Update README file with "quirks", minor changes needed, or expectations that the user should have when referencing the font's libraries.

    Possible Fix 2

    Update the keys within the array mapping to directly reflect the font's libraries. (MapIcon.swift and MaterialIcon.swift)

    Possible Fix 3

    Add a nil check to verify that the icon has been found. If not, throw or print a more specific error

    Related

    #37

    enhancement 
    opened by ChrisJohns-me 2
  • SwiftIconsFont for setting UIImage doesn't work

    SwiftIconsFont for setting UIImage doesn't work

    import SwiftIconFont
    
    let githubLogo = UIImage(from: .Octicon, code: "logo-github", textColor: .black, backgroundColor: .clear, size: CGSize(width: 150, height: 50))
    
    

    Error: "Type of expression is ambiguous without more context"

    I am using Swift 3.2, Xcode 9.1 Thanks

    opened by YKV 2
  • Material Icons font not registering properly

    Material Icons font not registering properly

    Hi,

    I love your library and I've been using it for almost all of my apps, but I've come across this error when using more than one Material Icons in one app.

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The operation couldn’t be completed. (com.apple.CoreText.CTFontManagerErrorDomain error 105 - Could not register the CGFont '<CGFont (0x7f8a9345fd60): MaterialIcons-Regular>')'
    

    Doing some research, it was complaining because it was trying to register the font again for some reason by calling FontLoader.loadFont(fontName) twice for the same font. Basically, UIFont.fontNamesForFamilyName(fontName) is still empty after the first registration.

    I wasn't sure why it was not working for Material Icons, but my workaround was to call CTFontManagerUnregisterGraphicsFont prior to calling CTFontManagerRegisterGraphicsFont, which is an ugly fix, but I didn't look into the problem deeper and needed to find quick fix.

    Anyways, I'm not sure if this is only happening to me but wanted to raise the issue for anyone else facing similar problem.

    Thank you

    bug 
    opened by indiesk 2
  • Crash when using both fontAwesome5 and fontAwesome5Solid

    Crash when using both fontAwesome5 and fontAwesome5Solid

    Seen under iOS (not tested on macOS). The root cause is both these fonts have the same family name, so Font.icon() doesn't load the second font after Font.fontNames(forFamilyName:) returns non-zero fonts.

    I have a fix, will submit PR.

    opened by sjpickup 1
  • Make public GetIconIndexWithSelectedIcon and GetFontTypeWithSelectedIcon

    Make public GetIconIndexWithSelectedIcon and GetFontTypeWithSelectedIcon

    In my app I fetch data for icons from webservice, I receive for example fa:file string for an icon, I need to display this icon into UIImage but I can not parse info without this functions.

    opened by damarte 1
  • Update SwiftIconBarButtonItem.swift

    Update SwiftIconBarButtonItem.swift

    Added public classifier to Class for making it accessable from Objective-C. Added public classifier to properties for making them accessable from Objective-C. Added @objc annotation for calling parseIcon function from Objective-C.

    opened by olcayertas 1
  • It doesn't work when using UIDocumentBrowserViewController

    It doesn't work when using UIDocumentBrowserViewController

    The code below works for a normal UIViewController

        let settingBarButtonItem = UIBarButtonItem(title: "settings", style: .plain, target: self, action: #selector(showSetting))
        settingBarButtonItem.icon(from: .materialIcon, code: "settings", ofSize: 20)
        navigationItem.rightBarButtonItem = settingBarButtonItem        
    

    But for UIDocumentBrowserViewController, additionalTrailingNavigationBarButtonItems is used to add extra items.

    additionalTrailingNavigationBarButtonItems = [settingBarButtonItem]
    

    When I did it, the icon always shows as a question mark.

    opened by guoyingtao 1
  • Replace NSString with String

    Replace NSString with String

    Thank you for a great framework. I love it.

    The function GetIconIndexWithSelectedIcon() does a curious conversion between NSString and String. I don't think this is necessary.

    Perhaps change from:

    for substring in ((text as String).split{$0 == " "}.map(String.init)) {
    

    Change to:

    for substring in icon.components(separatedBy: " ") {
    

    The SwiftIconFont.swift file uses NSString several places, where it could be a String.

    opened by neoneye 1
  • why my parser do not nice with fa

    why my parser do not nice with fa

    test:

    let button = UIButton(frame: CGRect(x: 120, y: self.view.frame.size.height - 200, width: 150, height: 30))
    button.setTitle("fa:chevron-left", for: .normal)
    button.setTitleColor(.black, for: .normal)
    button.parseIcon()
    self.view.addSubview(button)
    

    But the button says: fa:chevron_left

    When it comes to:

    button.setTitle("oc:logo-github", for: .normal)
    

    It's OK.

    opened by wakaryry 1
Releases(6.2.1)
Owner
sedat çiftçi
amele
sedat çiftçi
Use 1600+ icons (and more!) from FontAwesome and Google Material Icons in your swift/iOS project in an easy and space-efficient way!

Swicon Use 1600+ icons from FontAwesome and Google Material Icons in your iOS project in an easy and space-efficient way! The built-in icons are from

Zhibo 39 Nov 3, 2022
Google Material Design Icons Font for iOS

GoogleMaterialDesignIcons #Google Material Design Icons Font for iOS It is based on https://github.com/google/material-design-icons. it converts the m

Yuji Hato 365 Oct 19, 2022
🎢 Swift Library for Font Icons

Swift Library for Font Icons Please ★ this library. Now, you don't have to download different libraries to include different font icons. This SwiftIco

Saurabh Rane 781 Dec 6, 2022
SwiftUIFontIcon The easiest way to implement font icons in your SwiftUI project.

SwiftUIFontIcon The easiest way to implement font icons in your SwiftUI project. Usage The library is super super easy to use, just something like thi

Bui Dac Huy 81 Dec 27, 2022
OS font complements library. Localized font supported.

SwiftFontName SwiftFontName is font name complements and supports localized font library. You don't need to search font name any more with SwiftFontNa

Morita Naoki 114 Nov 3, 2022
Auto-generated icon font library for iOS, watchOS and tvOS

Iconic helps making icon fonts integration effortless on iOS, tvOS and watchOS. Its main component is in charge of auto-generating strongly typed Swif

Home Assistant 1.6k Nov 12, 2022
Font Awesome swift library for iOS.

Font Awesome Swift Follow me: @vaberer I like ★. Do not forget to ★ this super convenient library. Added UISegmentedControl & UITabbarItem & UISlider

Patrick Vaberer 746 Dec 17, 2022
Font Awesome support in Swift

MCFontAwesome Font Awesome v4.1.0 for Swift Font aliases has not been ported yet, in order to refer to a font you have to strip all the - (minus) insi

Matteo Crippa 19 Jun 9, 2020
Programmatically load custom fonts into your iOS and tvOS app.

FontBlaster Programmatically load custom fonts into your iOS and tvOS app. About Say goodbye to importing custom fonts via property lists as FontBlast

Arthur Ariel Sabintsev 1.1k Jan 3, 2023
Pretendard Fonts for iOS (Swift Package Manager)

PretendardKit Pretendard 1.3.3 을 기반으로 합니다. Install (Swift Package Manager) dependencies: [ .package(url: "https://github.com/wookeon/PretendardKit

Darth Vader 1 Jun 2, 2022
An inkwell to use custom fonts on the fly.

Inkwell Introduction In brief, Inkwell is a font library to use custom fonts on the fly. Inkwell takes responsibilities for: Downloading fonts from Go

Vinh Nguyen 151 Oct 10, 2022
SwiftUI Custom Fonts with working Xcode Previews

SwiftUI Custom Fonts with working Xcode Previews This is a small SwiftUI only app that demonstrates how to use custom fonts, where the custom fonts ar

Jeremy Gale 9 Aug 24, 2022
Google Material Design Icons for Swift and ObjC project

GoogleMaterialIconFont Google Material Design Icons for Swift and ObjC project This library is inspired by FontAwesome.swift Both Swift and Objctive-C

Yusuke Kita 146 Nov 8, 2022
Font management (System & Custom) for iOS and tvOS

UIFontComplete Font management (System & Custom) for iOS and tvOS Usage No more wasted time searching for names of UIFont fonts and no more surprises

Nicholas Maccharoli 1.3k Nov 14, 2022
This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

Server-side-Dynamic-Fonts This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

null 2 Mar 26, 2022
OpenSansSwift - Easily use the OpenSans font in Swift.

OpenSansSwift Easily use the OpenSans font in Swift. Why use OpenSansSwift frameworks ? The usual process of embedding any custom fonts in your IOS ap

Hemant Sapkota 42 Jan 29, 2022
A better choice for iOS Developer to use FontAwesome Icon with UI.😍

FontAwesomeKit.Swift ?? ?? A better choice for iOS Developer to use FontAwesome Icon with UI. ?? Support Swift 4.2 & iOS 8.0+ FontAwesome 4.7.0 Storyb

Qiun Cheng 192 May 16, 2022
Generator of settings icon by SF Symbols. Customisable background color and ready-use in table cell.

SPSettingsIcons Generate settings icons by Apple's SF Symbols. For safe using SFSymbols see SPSafeSymbols library. Installation Swift Package Manager

Sparrow Code 110 Dec 28, 2022
round icon drag control (made in swift) dock style

ASBubbleDrag Bubble drag control integrate in storyboard : Installation CocoaPods You can use CocoaPods to install ASBubbleDrag by adding it to your P

Alberto Scampini 46 Oct 12, 2022