Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS中将UILabel的字体名称设置为HelveticaNeue Thin?_Ios_Iphone_Objective C_Uifont - Fatal编程技术网

如何在iOS中将UILabel的字体名称设置为HelveticaNeue Thin?

如何在iOS中将UILabel的字体名称设置为HelveticaNeue Thin?,ios,iphone,objective-c,uifont,Ios,Iphone,Objective C,Uifont,我正在创建UILabel,对于该标签,我可以将字体名称设置为HelveticaNeue Regular、Light、UltraLight等,但我无法将字体名称设置为HelveticaNeue Thin,它无法按预期工作。我确实喜欢 label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:16]; 我也在谷歌上搜索过,没有找到任何解决方案。如何解决这个问题?谢谢 UIFontDescriptor *helveticaNeueFam

我正在创建UILabel,对于该标签,我可以将字体名称设置为HelveticaNeue Regular、Light、UltraLight等,但我无法将字体名称设置为HelveticaNeue Thin,它无法按预期工作。我确实喜欢

label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:16];
我也在谷歌上搜索过,没有找到任何解决方案。如何解决这个问题?谢谢

UIFontDescriptor *helveticaNeueFamily =
    [UIFontDescriptor fontDescriptorWithFontAttributes:
        @{ UIFontDescriptorFamilyAttribute: @"Helvetica Neue" }];
NSArray *matches =
    [helveticaNeueFamily matchingFontDescriptorsWithMandatoryKeys: nil];
如图所示的MatchingFontDescriptorWithMandatoryKeys:方法返回系统上所有Helvetica Neue字体的字体描述符数组,如HelveticaNeue、HelveticaNeue Medium、HelveticaNeue Light、HelveticaNeue Thin

您可以修改preferredFontForTextStyle返回的字体:通过应用符号特征,例如粗体、斜体、展开和压缩。您可以使用字体描述符修改特定的特征,如清单9-2所示

被引用

此字体不能直接应用

所以你可以自定义你的字体


此字体与iOS 7捆绑在一起,因此如果您的目标用户是iOS 7及以上版本的用户

label.font=[UIFont-fontWithName:@“HelveticaNeue-Thin”大小:16.0f]

会有用的


但是,如果您的目标是iOS 6.1及以下版本,则需要更新答案以支持swift

    let font = UIFont(name: "HelveticaNeue-Thin", size: 16.0)!

这对我很有效。在标签声明下方编写此代码

它使用相同的字体设置函数下的所有UILabel

[[UILabel appearance]setFont:[UIFont fontWithName:@"HelveticaNeue-Thin" size:32.0f]];
要将字体设置为特定UILabel,请使用以下代码:

[labelName setFont:[UIFont fontWithName:@"HelveticaNeue-Thin" size:15.0f]];

如果使用自定义字体,则必须将字体添加到项目中Font@HimanshuJoshiHelvetica Neue-Thin已经在iOS中捆绑(至少7个)。请检查这个:-也许你可以在这里找到你的答案,和我通过@HimanshuJoshi:)的链接一样。这似乎也适用于我,但谷歌建议它不应该工作,困惑。