thii / fontawesome.swift Goto Github PK
View Code? Open in Web Editor NEWUse FontAwesome in your Swift projects
License: MIT License
Use FontAwesome in your Swift projects
License: MIT License
If you press Edit-> Emoji & Symbols you get a list of special characters accessible in the Storyboard. How can I add the FontAwesome Icons there?
I have tried this framework to work with UIButton but I haven't been able to find a way around it to make it work.. Not sure if it supports UIButton yet but if it does it might be great to have an example in the readme file.
Thanks in advance!
@thii, any ideas if it's possible to use the spinners?
dispatch_once_t
is unavailable in Swift: Use lazily initialized globals insteadfontNamesForFamilyName
has been renamed to fontNames(forFamilyName:)
String
has no member substringToIndex
name:
in callclearColor()
has been renamed to clear()
Center
has been renamed to center
NSAttributedString
has been renamed to AttributedString
UIImage?
not unwrapped; did you mean to use !
or ?
?NSBundle
has been renamed to Bundle
NSURL
is not implicitly convertible to URL
; did you mean to use as
to explicitly convert?CFStringRef
has been renamed to CFString
I am seeing two errors in Swift 2.0:
FontAwesome.swift
line 39: as should be as!
line 659: advance should be advancedBy
I'm trying to set the disclosure indicator on a tableview to the FontAwesome CaretRight icon, which would be perfect for my app. Unfortunately I can't seem to do that because the .accessoryView property of the table cell must be of type UIView.
It would be great if this was an option in this pod. Thanks for considering it.
During build (debug) I receive such errors:
egrep: .../Pods/FontAwesome.swift: Is a directory
egrep: .../Pods/Target Support Files/FontAwesome.swift: Is a directory
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
In fact, project name generates it. What can we do with it not to have this error?
Xcode 7.3.1
FontAwesome.swift (0.7.3)
Hi there
I've written an extension that accepts Fontawesome css codes eg "fa-circle", as follows:
let icon = String.fontAwesomeIconWithCode("fa-circle")
Let me know if you'd like me to submit a PR.
The "dispatch_once" call inside of "fontAwesomeIconWithName()" is not effective. The icons table is setup every time the function is called because the 'token' var itself is not static, which can result in poor performance if used frequently.
public extension String {
public static func fontAwesomeIconWithName(name: String) -> String {
var icons: [String: String]?
var token: dispatch_once_t = 0 // This is reset to 0 on every call, so 'dispatch_once' does nothing
dispatch_once(&token) {
icons = [
"fa-adjust": "\u{f042}",...
If you debug this code (xcode debugger or just print), you will see that "token" is always 0 when the function is invoked. When using this function a lot, the performance was degraded surprisingly.
If you move the token / dictionary out to static symbols, the performance improves to expected levels.
Is it possible to use a label with text and a fontawesome icon in it? Or can a label only have a single font?
Hi, since I updated to cocopods 1.0.0
I receive this crash
Please advice
this is my podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target 'MyApp' do
pod 'ECSlidingViewController', '> 2.0.3'> 2.5'
pod 'AFNetworking', '
pod 'PNChart', '~> 0.7.1'
pod 'FontAwesome.swift'
end
I have a line in each of my view controllers to set the tab bar image. This is fine, but only works once you've clicked the tab. Is there anyway to load the images with the tab bar controller so they are loaded on the tab bar controller load?
FontAwesome.swift:120:49: Value of optional type 'CGDataProvider?' not unwrapped; did you mean to use '!' or '?'?
FontAwesome/FontAwesome.swift:98:16: Value of optional type 'UIImage?' not unwrapped; did you mean to use '!' or '?'?
In my pod file I have
pod 'FontAwesome.swift', :git => 'https://github.com/thii/FontAwesome.swift.git', :branch => 'swift-3.0'
I'm getting the following two errors when trying to build in func setupViews
in layoutSubViews
Since the repo's name includes .swift, certain run scripts can confuse this with a swift file and cause errors. Is it possible to change the name to something like FontAwesomeSwift or FontAwsome_swift to eliminate these errors?
With this code I get "could not find member .MapMarker"
UIImage.fontAwesomeIconWithName(.MapMarker, textColor: UIColor.grayColor(), size: 20)
With this code I get "cannot invoke 'fontAwesomeIconWithName' with and argument list of type '(FontAwesome,UIColor,Int)'
UIImage.fontAwesomeIconWithName(.MapMarker as FontAwesome, textColor: UIColor.grayColor(), size: 20)
However I have no problem using
String.fontAwesomeIconWithName(.MapMarker)
Is this just me or is this a bug?
Is there anyway to get this to work with OS X?
Hello,
I just finished my pod install of FontAwesome.swift with the exact podfile code you provided. My project is entirely empty. When I wrote "import FontAwesome" or "import FontAwesome_swift" into my ViewController.swift, I got this error.
How can I fix this?
Hello,
when it is expected to have support for iOS 9 / xcode 7 and Swift 2?
Thanks for the great library!
Hi, I'm experience some problems where I see 3 dots as ". . ." instead of the actual icon. Any suggestion on where might be the problem?
Is watchOS support something that is on your roadmap? If not, would you accept a pull request?
Hi, I have small problem. After installation FontAwesome by using CocoaPoads I have seen question marks in rectangle instead of icon. I don't know why ... ?
When using it with Auto Layout Constraints, the label font is set before it did layout.
The import FontAwesome
command is invalid.
It should read import FontAwesome_swift
Xcode: 7.2.1, Build version 7C1002
Carthage: 0.15.1
Contents of Cartfile: github "thii/FontAwesome.swift"
*** Building scheme "FontAwesome" in FontAwesome.xcodeproj
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64 /Users/rb/Projects/AFTR/aftr-ios/AFTR/Carthage/Checkouts/FontAwesome.swift/FontAwesomeTests/FontAwesomeTests.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
/Users/rb/Projects/AFTR/aftr-ios/AFTR/Carthage/Checkouts/FontAwesome.swift/FontAwesomeTests/FontAwesomeTests.swift:25:18: error: module 'FontAwesome' was not compiled for testing
A shell task failed with exit code 65:
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64 /Users/rb/Projects/AFTR/aftr-ios/AFTR/Carthage/Checkouts/FontAwesome.swift/FontAwesomeTests/FontAwesomeTests.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
It would be nice if this package could be installed via Carthage. I don't like copy&pasting source code into my projects...
Keep up the good work!
hi
when i ruling program app crash
in line fontURL = bundle.URLForResource(name, withExtension: "otf", subdirectory: "FontAwesome.swift.bundle")!
error : fatal error: unexpectedly found nil while unwrapping an Optional value
can you help me ?
hi, I have a problem, when I run the app, the compiler get an error in this line of fontAwesome.swift : "let data = NSData(contentsOfURL: fontURL!)!"
i think this error happen for link of font and class, isn't it?
I have a UILabel in a Storyboard.
I set the font to FontAwesome in the storyboard.
When running the app, I set the text using String.fontAwesomeIconWithName
, but I only see a squared ? [?]
However, if before that anywhere in the app I call UIFont.fontAwesomeOfSize
(probably because it calls the FontLoader) then it work as expected.
Is there anyway to get this to work without calling UIFont.fontAwesomeOfSize
explicitly?
When you use the UIImage extension to draw an image from a font icon, it clips the image for all the icons that are wider than tall. I think the bug is here:
https://github.com/thii/FontAwesome.swift/blob/master/FontAwesome/FontAwesome.swift#L81
The max
call should instead be a min
when determining the font size.
For example the icon fa-newspaper-o
when used with a font size of 30px actually generates an image that is 34px wide.
how to add font awesome icons in buttons of toolbar and navigation bar ?
I'm using vaadin icons in my java project.
https://vaadin.com/font-icons
Also many other free fonts exist:
http://speckyboy.com/2014/05/14/more-free-icon-fonts/
It should be nice to have some generic solution for font icons in swift.
Share common methods. Easy add new font. etc
Have you any idea how to do it?
Won't build with Swift 3.0
I have a problem with your library.
This is the Xcode's console:
dyld: Library not loaded: @rpath/libswiftSecurity.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/524AE979-D123-455E-83CC-DB96E01BC348/FoodApp.app/Frameworks/FontAwesome_swift.framework/FontAwesome_swift
Reason: image not found
no such moudle ! try many times
Carthage says:
Dependency "FontAwesome.swift" has no shared framework schemes for any of the platforms: Mac
If you believe this to be an error, please file an issue with the maintainers at https://github.com/thii/FontAwesome.swift/issues/new
Looking at a bit of the source, it looks like it uses UIKit, but perhaps it is worth having this work on Mac as well. Thoughts?
Hello,
I follow the installation guide:
After that I did import FontAwesome in my viewcontroller, then Xcode gave me No such module 'FontAwesome' error message. Please help me :)
p.s. I use Xcode 6.3.2
Is there any plans to update this for Swift 2.0? I get errors when trying to compile in Xcode 7
Thanks for this great library.
But How do you use icons like fa-angle-up?
I tried button.setTitle(String.fontAwesomeIconWithName(.fa-angle-up), forState: .Normal)
but failed
I try use your lib with carthage :), unfortunately the awesome texts always wrong
my codes
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: String.fontAwesomeIconWithName( FontAwesome.PlusSquare), style: .Plain, target: self, action: "createNote")
self.title = String.fontAwesomeIconWithName(.Github)
Please give me an advise to solve this.
Thanks,
Is there any way to use this from storyboard directly?
For some reason my php sends me article icons got from fontawesome.io lists
f0f6 (this is plain string, not Unicode character)
to convert it to \u{f0f6}" (singleUnicode character) I have to do:
let t="f0f6" //got this icon from server
let c=Int(strtoul(t, nil, 16))
let ch=Character(UnicodeScalar(c))
var s=""
s.append(ch)
iconLabel.text = s
I think we need func doing this, a kind of String.fontAwesomeIconWithUnicode
I think this found be a helpful function.
I added the FontAswome in swift using cocoa pods.
In file FontAwsome.swift on line no 29
let fontURL = bundle.URLForResource(name, withExtension: "otf")
fontURL is always nil, thats why application is crashing.
Hi!
How to fix this code to instead of the text was an icon?
@IBAction func btnApple(sender: UIButton) {
sender.enabled = false
sender.titleLabel?.font = UIFont.fontAwesomeOfSize(20)
sender.titleLabel?.textColor = UIColor.blackColor()
sender.setTitle(String.fontAwesomeIconWithName(.Apple), forState: .Normal)
}
Thank you)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.