So I am trying to use this font http://fortawesome.github.com/Font-Awesome/. I've added the font as a resource and put it in the plist file. Here's how I am using it:
[homeFeedButton.titleLabel setFont:[UIFont fontWithName:@"fontawesome" size:8]];
NSString *str = [NSString stringWithFormat:@"%C", @"\f030"];
However this doesn't work. Does anyone know how to use this font in an Xcode project?
You can work with types declared in Swift from within the Objective-C code in your project by importing an Xcode-generated header file. This file is an Objective-C header that declares the Swift interfaces in your target, and you can think of it as an umbrella header for your Swift code.
We designed Font Awesome for use with inline elements, and we recommend that you stick with a consistent element in your project. We recommend using <i> element with the Font Awesome CSS classes for the style class for the style of icon you want to use and the icon name class with the fa- prefix for the icon you want to use.
Font Awesome uses that combination. If a page is cached, and loaded without the mouse over the window (i.e. hit the refresh button or load something in an iframe) then the page gets rendered before the font loads. Hovering over the page (body) will show some of the icons and hovering over the remaining icons will show those as well.
Font Awesome uses that combination. If a page is cached, and loaded without the mouse over the window (i.e. hit the refresh button or load something in an iframe) then the page gets rendered before the font loads. Hovering over the page (body) will show some of the icons and hovering over the remaining icons will show those as well.
In Swift:
Font Awesome Cheatsheet.
Tutorial on how to integrate the font called "Font Awesome" in your Xcode project.
Common Mistakes With Adding Custom Fonts to Your iOS App
let label = UILabel(frame: CGRectMake(0, 0, 100, 100))
label.font = UIFont(name: "FontAwesome", size: 40)
let myChar: UniChar = 0xF180
label.text = String(format: "%C", myChar)
self.view.addSubview(label)
BEST solution for FA with XCode:
That's it.
If you need to change the icon in the code - you can paste 1st step inside your code too:
Not sure you ever got this working properly, but there's now a couple of nice projects on github:
https://github.com/alexdrone/ios-fontawesome - which gives you a category for NSString which offers basic help using FontAwesome.
and https://github.com/leberwurstsaft/FontAwesome-for-iOS which gives you a NSString category with fontAwesomeIconStringForIconIdentifier
and also an UIImageView
subclass: FAImageView
It is because your +[NSString stringWithFormat:]
method contains the literal for a unichar, not an NSString, which is an object that uses %@, which is beside the point because literal'ing a literal is redundant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With