如何在Xcode项目中集成和使用Font Awesome与Objective-C或Swift? [英] How to integrate and use Font Awesome with Objective-C or Swift in an Xcode project?

查看:216
本文介绍了如何在Xcode项目中集成和使用Font Awesome与Objective-C或Swift?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用这种字体 http://fortawesome.github.com/Font-Awesome / 。我已将字体添加为资源并将其放在plist文件中。以下是我如何使用它:

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"];

但是这不起作用。有没有人知道如何在Xcode项目中使用这种字体?

However this doesn't work. Does anyone know how to use this font in an Xcode project?

推荐答案

这是因为你的 + [ NSString stringWithFormat:] 方法包含一个unichar的文字,而不是一个NSString,它是一个使用%@的对象,它不在这一点,因为文字的文字是多余的。

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.

这篇关于如何在Xcode项目中集成和使用Font Awesome与Objective-C或Swift?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆