如何在iOS中将Pictos字体应用于UIButton [英] How to apply Pictos font to UIButton in iOS

查看:109
本文介绍了如何在iOS中将Pictos字体应用于UIButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用带有主页图标的主页"按钮,但是我想使用实际字体而不是图形.

I want to use Home button with home icon, but I want to use actual font instead of graphics.

例如,我将UIButton标题设置为"H"并为其设置Pictos字体,以便它应自动将按钮文本转换为相应的图形(在这种情况下为主页图标)

For e.g) I will set UIButton title to "H" and set Pictos font it, so that it should automatically convert button text into corresponding graphics(In this case home icon)

如何使用pictos字体?

How to do it using pictos font?

推荐答案

最后从photoshop中获得了.otf格式的"Pictos"字体.在Photoshop中可以使用Pictos字体.

Finally got "Pictos" font in .otf format from photoshop. Pictos font is available in photoshop.

步骤:

  1. 从photoshop中导出.otf格式的Pictos字体.
  2. 将自定义字体添加到您的应用程序中,您可以将其添加到XCode项目中.
  3. 修改application-info.plist文件.将密钥应用程序提供的字体"添加到
    新行.为已添加的pictos字体添加一项.

  1. Export Pictos font in .otf format from photoshop.
  2. Add custom font to your application, you can add them to the XCode project.
  3. Modify the application-info.plist file. Add the key "Fonts provided by application" to a
    new row. Add one item for pictos font you have added.

创建按钮并设置Pictos字体.

Create button and set Pictos font.

UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
homeButton.frame = CGRectMake(0, 0, 34 , 33);
[homeButton setTitle:@"H" forState:UIControlStateNormal];
homeButton.titleLabel.font = [UIFont fontWithName:@"Pictos" size:22];

  • 您将看到带有主页"图标的按钮,例如
  • You will see button with Home icon like
  • 注意:您可以通过设置适当的标题文本来设置不同的图标.

    Note: You can set different icons by setting proper title text.

    这篇关于如何在iOS中将Pictos字体应用于UIButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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