繁体   English   中英

Objective-C FontAwesome

[英]Objective-C FontAwesome

我正试图在iOS应用程序上运行FontAwesome并可以使用一点帮助。 我有以下iOS代码:

UIBarButtonItem * viewDeckButton = [[UIBarButtonItem alloc]
                                    initWithTitle:@"\uf0c9"
                                    style:UIBarButtonItemStyleBordered
                                    target:self.viewDeckController
                                    action:@selector(toggleLeftView)];

NSDictionary * customTextAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIFont fontWithName:@"FontAwesome" size:14.0],
                                  UITextAttributeFont,
                                  nil];

[viewDeckButton setTitleTextAttributes:customTextAttrs forState:UIControlStateNormal];

@"\"对应于css类,icon-reorder。 该字体似乎安装在我的系统上(参见http://cl.ly/image/2F1x1z2H0i2N )。 我正在获取标准的盒子字符,就像没有加载字体一样(参见http://madmonkdev.com/badchar.png )。

任何帮助,将不胜感激。

您需要将字体文件(.ttf)添加到应用程序的资源包中,并在Info.plist中注册该字体。 你做过这些事吗?

在您的系统上安装字体是无关紧要的。

我无法让unicode char变得正确。

我通过下载Fontforge( http://fontforge.org/ )并在base10中找到字形来实现它。 然后通过代码访问它

unicode aChar = 65451
NSString *iconChar = [NSString stringWithCharacters:&aChar length:1];

查看此项目的字体示例: https//github.com/AlexDenisov/FontasticIcons

字体名称也可以与文件名不同。 所以可能需要使用“FontAwesome”在代码中访问字体文件“font-awesome.ttf”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM