且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iOS中将Pictos字体应用于UIButton

更新时间:2023-12-01 22:07:10

最后从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.