{"id":13311701,"url":"https://github.com/Xiaoye220/JustIconFont","last_synced_at":"2025-03-10T17:30:42.350Z","repository":{"id":56917042,"uuid":"114945517","full_name":"Xiaoye220/JustIconFont","owner":"Xiaoye220","description":"🐢 IconFont library for Swift.  Support FontAwesome, Iconic, Ionicons, MaterialIcons, Octicons and custom icons. Using iconfont by Enum.","archived":false,"fork":false,"pushed_at":"2019-05-27T11:33:34.000Z","size":1610,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T17:14:15.140Z","etag":null,"topics":["custom-iconfont","enum","fontawesome","icon-font","iconic","ionicons","materialicon","octicons","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xiaoye220.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-21T00:54:19.000Z","updated_at":"2025-01-18T07:26:39.000Z","dependencies_parsed_at":"2022-08-21T03:50:56.285Z","dependency_job_id":null,"html_url":"https://github.com/Xiaoye220/JustIconFont","commit_stats":null,"previous_names":["xiaoye220/iconfont"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xiaoye220%2FJustIconFont","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xiaoye220%2FJustIconFont/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xiaoye220%2FJustIconFont/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xiaoye220%2FJustIconFont/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xiaoye220","download_url":"https://codeload.github.com/Xiaoye220/JustIconFont/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242892571,"owners_count":20202558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-iconfont","enum","fontawesome","icon-font","iconic","ionicons","materialicon","octicons","swift"],"created_at":"2024-07-29T18:02:18.588Z","updated_at":"2025-03-10T17:30:42.345Z","avatar_url":"https://github.com/Xiaoye220.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![pod](https://img.shields.io/badge/pod-JustIconFont-brightgreen.svg)\n![iOS](https://img.shields.io/badge/iOS-8.0-green.svg)\n![lisence](https://img.shields.io/badge/license-MIT-orange.svg)\n![swift](https://img.shields.io/badge/swift-5.0-red.svg)\n\n# IconFont\n\nUse iconfont by Enum.\n\nSupport custom iconfont (you can make a custom iconfont from [iconfont.cn](http://www.iconfont.cn/)、[iconmoon](https://icomoon.io/))\n\nSupport open source icon : \n\n* [FontAwesome v5.8.1 (Free)](http://fontawesome.io/icons/)\n* [Iconic v1.1.1](https://useiconic.com/open)\n* [Ionicons v4.5.5](https://ionicons.com/)\n* [MaterialIcons v3.0.1](https://github.com/google/material-design-icons)\n* [Octicons v8.4.2](https://octicons.github.com/)\n\n## CocoaPods\n\n```\nuse_frameworks!\npod 'JustIconFont'\n\n# support to FontAwesome、Iconic、Ionicons、MaterialIcons、Octicons\npod 'JustIconFont/FontAwesome'\npod 'JustIconFont/Iconic'\t\t\npod 'JustIconFont/Ionicons'\t\npod 'JustIconFont/MaterialIcons'\t\npod 'JustIconFont/Octicons'\n```\n\n## Preview\n\n![screenshot](screenshot/screenshot.png)\n\n## Usage\n\n### Basic\n\nEvery icon can present as UIImage or NSAttributedString. \n\n\u003e We can create UIImage with fontSize or imageSize. One is created according to the size of the font.  Another is created according to the size of the image.\n\n```swift\n// NSAttributedString\nlet attributedString = NSAttributedString.iconFont(Octicons.logoGithub, fontSize: 25)\nlabel.attributedText = attributedString\nbutton.setAttributedTitle(title: attributedString, for: .normal)\n\nlet attributes = NSAttributedString.attributes(with: Octicons.logoGithub, fontSize: 30)\ntabBarItem.title = Octicons.logoGithub.unicode\ntabBarItem.setTitleTextAttributes(attributes, for: .normal)\n\nbarButtonItem.title = Octicons.logoGithub.unicode\nbarButtonItem.setTitleTextAttributes(attributes, for: .normal)\n\n// UIImage with fontSize. UIImage size is 39 * 30\nlet image = UIImage.iconFont(Octicons.logoGithub, fontSize: 30)\nimageView.image = image\nbutton.setImage(image, for: .normal)\ntabBarItem.image = image\ntabBarItem.selectedImage = image\nbarButtonItem.image = image\n\n// UIImage with imageSize. UIImage size is 30 * 30\n// image will scaled to fit with fixed aspect.\nlet image = UIImage.iconFont(Octicons.logoGithub, imageSize: CGSize(width: 30, height: 30))\nimageView.image = image\n```\n\n### Extensions\n\nThere are some extensions for UIKit. \n\n#### UILabel\n\n```swift\n// use FontAwesome Brands\nlabel.iconFont(size: 25, icon: FontAwesome.Brands.github)\nlabel.iconFont(size: 25, icon: FontAwesome.Brands.github, color: .red)\n```\n\n#### UIImageView\n\n```swift\n// use Octicons\nimageView.iconFont(Octicons.logoGithub) // imageSize = imageView.frame.size\nimageView.iconFont(Octicons.logoGithub, fontSize: 30)\nimageView.iconFont(Octicons.logoGithub, imageSize: CGSize(width: 30, height: 30))\n```\n\n#### UIButton\n\n```swift\n// if color is nil, icon's color is depend on `tintClor`\nbutton.iconFont(Octicons.logoGithub, fontSize: 30)\n\nbutton.iconFont(Octicons.logoGithub, fontSize: 30, color: .lightGray, for: .normal)\nbutton.iconFont(Octicons.logoGithub, fontSize: 30, color: .red, for: .highlighted)\n```\n\n#### UIBarButtonItem\n\n```swift\n// use MaterialIcons\n// if color is nil, icon's color is depend on `tintClor`\nbarButtonItem.iconFont(size: 25, icon: MaterialIcons.book)\nbarButtonItem.iconFont(size: 25, icon: MaterialIcons.book, color: color)\n```\n#### UITabBarItem\n```swift\n// use FontAwesome Solid\ntabBarItem.title = \"solid\"\n// if color is nil, icon will present the default color\ntabBarItem.iconFont(FontAwesome.Solid.addressBook, fontSize: 25)\ntabBarItem.iconFont(FontAwesome.Solid.addressBook, fontSize: 25, color: .red, for: .selected)\n\n// use FontAwesome Regular\nrightTabBarItem.title = \"regular\"\nrightTabBarItem.iconFont(FontAwesome.Regular.addressBook, fontSize: 25)\nrightTabBarItem.iconFont(FontAwesome.Regular.addressBook, fontSize: 25, color: .red, for: .selected)\n```\n## Custom IconFont\n\nCustom IconFont should implement protocol IconFontType\n\n### Create\n```swift\npublic enum MyIconFont: String {\n    case feedback = \"\\u{e656}\"\n    case search = \"\\u{e651}\"\n    case home = \"\\u{e64f}\"\n    case clock = \"\\u{e648}\"\n    case like = \"\\u{e643}\"\n    case shoppingCart = \"\\u{e63f}\"\n}\n\n/// Implement protocol IconFontType\npublic extension MyIconFont: IconFontType {\n    /// Font family name. The fully specified name of the font. \n    /// This name incorporates both the font family name and \n    /// the specific style information for the font.\n    var name: String {\n        return \"iconfont\"\n    }\n    \n    ///  path of TTF file\n    var filePath: String? {\n        return Bundle.main.path(forResource: \"iconfont\", ofType: \"ttf\")\n    }\n    \n    var unicode: String {\n        return self.rawValue\n    }\n}\n\n/// There is another way to setup custom iconfont\n/// If your TTF file's name is equel to font family name\n/// you just need to implement protocol IconFontEnumType and return font name\npublic extension MyIconFont: IconFontEnumType {\n    var name: String {\n        return \"iconfont\"\n    }\n}\n```\n### Usage\n```swift\nlabel.iconFont(MyIconFont.clock, fontSize: 25)\nlabel.iconFont(MyIconFont.feedback, fontSize: 30)\nlabel.iconFont(MyIconFont.shoppingCart, fontSize: 35)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXiaoye220%2FJustIconFont","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FXiaoye220%2FJustIconFont","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXiaoye220%2FJustIconFont/lists"}