如何更改uilabel的字体?

发布于 2024-12-11 10:31:41 字数 155 浏览 0 评论 0原文

我想更改标签的字体。我正在使用的字体如图所示。 如何在我的应用程序中使用它。我已经添加了 .plist,如图所示。但它不能正常工作。我如何管理它?

提前致谢...在此处输入图像描述

I want to change the font of label. And font which i am using is shown in image.
How use it in my application. I have already add in .plist as show in image. But it not working proper. How i manage it?

Thanks in advances...enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

水晶透心 2024-12-18 10:31:41

使用它以编程方式设置字体:

[TheLabelName setFont:[UIFont fontWithName:@"American Typewriter" size:18]];

Use this to set the font programmatically:

[TheLabelName setFont:[UIFont fontWithName:@"American Typewriter" size:18]];
夜唯美灬不弃 2024-12-18 10:31:41

IOS 中的自定义字体

仅设置标签字体

yourLabel.font = [UIFont fontWithName:@"CloisterBlack" size:64.0];

Custom fonts in IOS

to set an label font just

yourLabel.font = [UIFont fontWithName:@"CloisterBlack" size:64.0];
错爱 2024-12-18 10:31:41

如果您想使用标准字体,那么就像通常一样:您可以在界面构建器中为此标签设置它,或者以编程方式为此标签设置它。

如果您想应用自定义字体(根据您想要的图像),那么您可以这样做。 你也

     UIFont *font = [UIFont fontWithName:@"MyFont" size:20];
     [label setFont:font];

可以探索这个参考:
我可以在 iPhone 应用程序中嵌入自定义字体吗?< /a>

它可能对你的情况有用。

If you want to use the standard font, then just as usually: you can set it in the interface builder for this label or programmatically for this label.

If you want to apply your custom font (according to the image you want that), then you can do smth. like

     UIFont *font = [UIFont fontWithName:@"MyFont" size:20];
     [label setFont:font];

Also you can explore this ref:
Can I embed a custom font in an iPhone application?

it might be useful in your case.

草莓酥 2024-12-18 10:31:41

在资源中添加自定义字体文件 .ttf 并在每次想要显示格式化字体时使用,例如

headLbl.font = [UIFont fontWithName:@"Museo-700" size:20.f];

Add your custom font file .ttf in resourse and use every time when you want to display formatted font like

headLbl.font = [UIFont fontWithName:@"Museo-700" size:20.f];
濫情▎り 2024-12-18 10:31:41

在您的资源目录中添加一个字体,就像您已经完成的此图像一样,现在主要的事情是您无法写入您添加的字体的名称,因为它检查我的图像字体名称为 ROCKB.ttf 但我已经写了 Rockwell -粗体,因此您必须检查代码中安装的名称,然后从那里选择名称,然后将该名称放入标签中,字体现在将反映标签。在此处输入图像描述

label.font = [UIFont fontWithName:@"Rockwell-Bold" size:20];

和字体系列通过此代码 NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"家族名称:%@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@" 字体名称:%@", [fontNames objectAtIndex:indFont]);
}
[字体名称发布];
}
[家族发布];

Add a font in your resource directory like this image that you have already done now main thing you cann't wirte the name of the font that you have added as it is check my image font having name ROCKB.ttf but i have write the Rockwell-Bold so you have to check by what name it has been installed in your code then pick the name from there and then put that name in lable the font will reflect the label now.enter image description here

label.font = [UIFont fontWithName:@"Rockwell-Bold" size:20];

and font family by this code NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@" Font name: %@", [fontNames objectAtIndex:indFont]);
}
[fontNames release];
}
[familyNames release];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文