是否可以在应用中使用iOS 7的改良Helvetica? [英] Is it possible to use iOS 7's modified Helvetica in apps?

查看:104
本文介绍了是否可以在应用中使用iOS 7的改良Helvetica?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iOS 7,Apple制作了一个特殊修改版的Helvetica Thin / Light,它具有圆周期和冒号:

For iOS 7, Apple made a special modified version of Helvetica Thin/Light that has rounded periods and colons:

将此与在Xcode中使用Helvetica-Neue Thin或Helvetica-Neue Light进行比较:

Compare this to using Helvetica-Neue Thin or Helvetica-Neue Light in Xcode:

是否可以开发具有圆形冒号和句号的特殊修改版本的应用程序?

Is it possible to develop apps with the special modified version with the rounded colons and periods?

EDIT :这些圆形冒号和周期不是由Apple自定义设计的,它们是字符替换,您可以在您喜欢的字体字形查看器中看到它们。

EDIT: Turns out these round colons and periods are not custom designed by Apple, they are "character alternates" and you can see them in your favorite font glyph viewer.

推荐答案

以下是如何做到这一点。即使阅读文档,也很不清楚。

Here's how to do it. Even reading the documentation, it's very unclear.

首先,你必须得到一个字体的特征,这将给你在<$ c $中使用的常量C> UIFontDescriptorFeatureSettingsAttribute 。我从这篇文章获得了我的信息。

First, you have to get the characteristics of a font, which will give you the constants to use in your UIFontDescriptorFeatureSettingsAttribute. I got mine from this post.

这为您提供了功能类型标识符键,以及它们的值选项,特征选择器标识符键。

This gives you feature type identifier keys, and your options for their values, the feature selector identifier keys.

NSArray *timerDisplaySettings = @[
                                      @{ UIFontFeatureTypeIdentifierKey: @(6),
                                        UIFontFeatureSelectorIdentifierKey: @(1)
                                     },
                                      @{ UIFontFeatureTypeIdentifierKey: @(17),
                                        UIFontFeatureSelectorIdentifierKey: @(1)
                                        }];

然后通过添加到描述符来创建字体描述符 - 这样你就可以指定字体名称和家庭通过 UIFont

then you create a font descriptor by adding to a descriptor - this way you can specify the font name and family via UIFont:

UIFont *font = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:32];

UIFontDescriptor *originalDescriptor = [font fontDescriptor];
UIFontDescriptor *timerDescriptor =[originalDescriptor fontDescriptorByAddingAttributes: @{ UIFontDescriptorFeatureSettingsAttribute: timerDisplaySettings }];

然后,关闭循环并使用描述符创建字体。 (大小0.0仅表示我们没有将其从原始大小32缩放。

Then, close the loop and create the font with your descriptor. (The size "0.0" simply means we aren't scaling it from its original size of 32.

UIFont *timerFont = [UIFont fontWithDescriptor: timerDescriptor size:0.0];

这篇关于是否可以在应用中使用iOS 7的改良Helvetica?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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