为什么这个标签显得没有风格? [英] Why is this label appearing unstyled?

查看:200
本文介绍了为什么这个标签显得没有风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  NSInteger偏移量= 0;我们在开始以编程方式开发一个屏幕时, 
UIFont * font = [UIFont fontWithName:@Scurlocksize:80];
UILabel * label = [[UILabel alloc] initWithFrame:(CGRectMake(20,40 + offset,width,20))];
[label setFont:font];
[label setText:@Hello,world!];
[self.view addSubview:label];

Hello,world!确实出现在预定的坐标上,但我还没有找到改变字体系列或字体大小的方法。 Scurlock是一个包含在应用程序资源中的TrueType字体。



我怎么能说用这个坐标显示这个字体在这个坐标上,用一个UILabel或者类似RTLabel (我设法得到大胆,但不改变字体或字体大小)?

- 编辑 -



 < key>字体在支持文件的顶部有Scurlock.TTF由应用程序< / key>提供
< array>
< string> Scurlock.TTF< / string>
< / array>

这会导致打印出一个答案的列表中有一个0,并且行为与AFAICT相同是否指定Scurlock或Scurlock.TTF。

解决方案

•在Copy Bundle Resources下检查您的目标以确保字体实际上包含在捆绑包中。



•如果您还没有将字体添加到plist中。



•使用


$ b

 来检查字体名称([UIFont familyNames]中的NSString *系列)
{
NSLog(@%@,family);
for(NSString * name in [UIFont fontNamesForFamilyName:family])
NSLog(@%@,name);

请参阅本指南

I have, in starting to programmatically develop a screen, the following:

NSInteger offset = 0;
UIFont *font = [UIFont fontWithName:@"Scurlock" size:80];
UILabel *label = [[UILabel alloc] initWithFrame:(CGRectMake(20, 40 + offset, width, 20))];
[label setFont:font];
[label setText:@"Hello, world!"];
[self.view addSubview:label];

The "Hello, world!" does appear at the intended coordinates, but I have not found a way to change either the font family or font size. Scurlock is a TrueType font included in the app's resources.

How can I say "Display this text in that font at these coordinates" with a UILabel or something comparable like an RTLabel (which I managed to get bold, but not change the font or font size)?

--EDIT--

I have Scurlock.TTF at the top of Supporting Files and the following from the plist:

<key>Fonts provided by application</key>
<array>
    <string>Scurlock.TTF</string>
</array>

This results in one 0 in the list printed out for one answer, and the behavior is AFAICT the same whether I specify Scurlock or Scurlock.TTF.

解决方案

• Check your target under "Copy Bundle Resources" to make sure that the font is actually included in the bundle.

• Add the font to your plist if you haven't yet.

• Double check the font name using

for (NSString* family in [UIFont familyNames])
{
    NSLog(@"%@", family);
    for (NSString* name in [UIFont fontNamesForFamilyName: family])
        NSLog(@"  %@", name);
}

See this guide.

这篇关于为什么这个标签显得没有风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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