Coder Social home page Coder Social logo

segecey / swifticonfont Goto Github PK

View Code? Open in Web Editor NEW
1.2K 20.0 118.0 2.64 MB

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

License: MIT License

Swift 96.59% Ruby 3.12% Objective-C 0.20% HTML 0.09%
uitextfield uilabel uibutton swift cocoapods icons font fonts uibarbuttonitem

swifticonfont's Introduction

👋

swifticonfont's People

Contributors

alexeydonov avatar anthropohedron avatar bauermusic avatar code918 avatar colinmorelli avatar czrml avatar damarte avatar ddcrobert avatar edumucelli avatar fistofthenorthstar avatar icanswiftabit avatar ipavlidakis avatar jacobbullock avatar jcsplash avatar masashi-sutou avatar mofneko avatar olcayertas avatar omidgolparvar avatar rdougan avatar salbertson avatar segecey avatar seigel avatar simonpickup avatar sokichifujita avatar sync avatar tnantoka avatar wevtimoteo avatar yushann avatar yysskk avatar zepojo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swifticonfont's Issues

Using IonIcon crashes the app

I am currently using the Pod of SwiftIconFont. First of all, thank you for your work on that.

However, it crashes when I try to use Ionicon. Here is the extract of relevant code:

self.standsIconLabel.font = UIFont.iconFontOfSize(.Ionicon, fontSize: 25.0)

It points to a error at

// FontLoader.swift, line 22
let data = NSData(contentsOfURL: fontURL)!

fatal error: unexpectedly found nil while unwrapping an Optional value
On the other hand, using:

self.standsIconLabel.font = UIFont.iconFontOfSize(.Ionicon, fontSize: 25.0)

works perfectly.

CHANGELOG.md

Please put changelog.md, so others can easily track which version of library supports which version of swift.

No support with attributedText?

                            let text = x + " <light>fa:chevronright</light>"
                            let lightStyle = StringStyle(.color(.red))
                            let style = StringStyle(
                                .font(UIFont.systemFont(ofSize: 18)),
                                .lineHeightMultiple(1.8),
                                .color(.darkGray),
                                .xmlRules([
                                    .style("light", lightStyle),
                                    ])
                            )
                            let attrText = text.styled(with: style)
                            view.textAlignment = .left
                            view.contentInsets = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
                            view.attributedText = attrText
                            view.parseIcon()

The view is a label.
I use BonMot to style text.
But the parsed text is with no style.
The icon is shown correctly.

Change button icon causes blink color

I'm using this method to setup a button in a custom uitableviewcell:

func buildIconText(button: UIButton, fontSize: CGFloat, fontName: String, text: String?, color: UIColor){

  button.setTitleColor(color, for: .normal)
  button.titleLabel?.font = UIFont.icon(from: .fontAwesome, ofSize: fontSize)
  button.titleLabel?.text = String.fontAwesomeIcon(fontName)

   if text != nil {
       button.titleLabel?.text?.append(" ")
       button.titleLabel?.text?.append(text!)
    }

		button.parseIcon()
}

This cause a flash blink on color when change the icon + text. The color pass by blank, blue tint, and finally the color received by params.
Someone knows how i can change the title of button, without blink color text ?

UITabBarItem color problem

Hi dear:
Thanks at first! I cannot change image color when i use UITabBarItem! Can you help me? Thanks!

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

On completion callback when rendered

Is there a way I could call a function once icon has rendered?
Right now I'm setting it like this:

func setIconWithSize(icon: String, font: Fonts, size: CGFloat) {
        self.setTitle(String.fontIonIcon(icon), for: .normal)
        self.titleLabel?.font = UIFont.icon(from: font, ofSize: size)
    }

The problem is, initially I have my button hidden, and I unhide it right after I call this function:

shuffleButton.setIconWithSize(icon: shuffleIcon, font: .Ionicon, size: 24)
shuffleButton.isHidden = false

But it unhides button right at a millisecond before icon gets rendered.
So, I see old icon changing to a new one.

It be cool, to have some callback completion method

error on Xcode 9.4.1

The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

Doesn't work on Xcode 9.4.1

Problem with Material icon with two or more words

When i use material icon with one word for ex:"accessibility", i don't have any problem, but when i try to use icons with two or more words for ex: "flight_land" the icon doesen't appear. Here is an image http://imgur.com/OJ3mO66 and my code in addition

cellIcon.font = UIFont.icon(from: .MaterialIcon, ofSize: 30.0)
cellIcon.text = String.fontMaterialIcon(icon.replacingOccurrences(of: "ic_", with: "").replacingOccurrences(of: "_", with: "-"))

Suggest to change the version number `2.7.2`

I did a pod update recently and found build error in project due to SwiftIconFont.
After some debugging, I found SwiftIconFont updated from 2.7.1 to 2.7.2

The version 2.7.2 have migrated to support Swift 4.0. But I still use Swift 3.2 to compile and got the errors.
It seems not a minor change. So I suggest to use a major version number to tag it.

It will be good to have a note on README too.

Thanks for your effort to maintain this lib.

UPDATE FontAwesome.ttf

Whatsapp did not appear. I've been looking for a while. Fixed it by manually updating the FontAwesome.ttf file.

Font Awesome 5

Hey buddy, would you be able to add Font Awesome 5 Icons? :)

Viewing Actual Fonts in Storyboard

The lazy loading way of loading icons is great. However in storyboard, the icon name shows rather than the icon itself. Ex. the icon for "More" displays as "io:more" in storyboard rather than the actual "More Icon"

Any way this could be resolved?

Is there any different between `NSRange` and `_NSRange`

There is a question at SwiftIconFont.swift, I found that _NSRange is used in func parseIcon(), because it is a type alias of NSRange, there should be no difference, I want to confirm your intention of using _NSRange, thanks.

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

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.

Cocoapod Incomplete?

The extensions directory isn't being copied down via the default pod instal or update command. As a result, none of the extensions for classes like UIImageView are available.

I had to clone your repository, and change my Podfile like this:

pod 'SwiftIconFont', :path => '~/Developer/SwiftIconFont'

Where ~/Developer is where I have an unmodified close of your repository.

I'm not an expert by any means in Cocoapod pod spec files, but my gut is the Extensions directory needs to be added to it. The way I read it, only the Classes and .ttf resources are getting included.

CocoaPods missing files

Cocoa pods seems to be missing necessary files

no references to SwiftBarButtonItem, etc. Your pod spec here is versioned @ 2.5, but cocoa pods only has 2.4 registered. So not sure if there was an error uploading podpsec

Xcode8.3.1 warning - conditional downcast

Great project.

Warning text:

/Path/To/SwiftIconFont.swift:305:56:
Conditional downcast from 'String?' to 'NSString' is a bridging conversion; did you mean to use 'as'?

Xcode 8.3.1 (8E1000a)

Solution

Change from

guard let currentTitle = self.titleLabel?.text as? NSString else { return }

Change to

guard let currentTitle = self.titleLabel?.text as NSString? else { return }

Swift 3

When will you release swift 3 compatible version? Thanks

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.

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.

can you support Tabbar

although I'm able to get the image on the tabbar i have issues when selected to change the image.

need public extensions

I was testing this out and it looks like the UIBarButtonItem and UITabBarItem extensions aren't public.

I edited this and changed them to public and then the methods work fine. I figured this was a simple enough fix it wasn't worth creating a PR.

Carthage tvOS Support

Hey 🙌

First of all: Great work with SwiftIconFont!
I'm enjoying and using it as a sub-dependency in the STLocationRequest library.

Are there any plans to add an tvOS target and scheme to SwiftIconFont to allow using it via Carthage when building for thetvOS platform?

$  carthage update --platform tvOS

*** Skipped building SwiftIconFont due to the error:
Dependency "SwiftIconFont" has no shared framework schemes for any of the platforms: tvOS

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.