ranesr / SwiftIcons

🎢Swift Library for Font Icons - ★ this library

Home Page:https://ranesr.github.io/SwiftIcons/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way can use String to set Icon?

icefox57 opened this issue · comments

normally use enum to tell func what icon u want ?
cell.imgvIcon.setIcon(icon: .fontAwesome(.addressBook))

but if the icon type is from server, can i use string to set icon ?
cell.imgvIcon.setIcon(iconString: "fontAwesome.addressBook")

i found .text can get name of this icon.
Can i use this name as parameter?

.text returns the unicode character for the icon, as specified by the icon font's creator. At it's simplest level, this library simply is just a mapping dictionary of human-readable names to the unicode character equivalents.

Could you use text instead of enum? Well you could add a method to do the lookup, but I don't really see any point too that, enum's are better.

Using remote font files? If your loading the remote font's to replace local ones, then I don't see an issue (although I can't see much benefit), the unicode characters will be the same and everything should work with the current enums.

If you're trying to load a remote font file for an icon font that isn't supported or a newer version containing icon's that aren't supported, then you'll need to add the character mappings to this library (you could even PR the update for others to use). The library has no way of dynamically inferring a human-readable name from the font files characters, they are all hardcoded.