如何更改uilabel的字体?
我想更改标签的字体。我正在使用的字体如图所示。 如何在我的应用程序中使用它。我已经添加了 .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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用它以编程方式设置字体:
Use this to set the font programmatically:
IOS 中的自定义字体
仅设置标签字体
Custom fonts in IOS
to set an label font just
如果您想使用标准字体,那么就像通常一样:您可以在界面构建器中为此标签设置它,或者以编程方式为此标签设置它。
如果您想应用自定义字体(根据您想要的图像),那么您可以这样做。 你也
可以探索这个参考:
我可以在 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
Also you can explore this ref:
Can I embed a custom font in an iPhone application?
it might be useful in your case.
在资源中添加自定义字体文件 .ttf 并在每次想要显示格式化字体时使用,例如
Add your custom font file .ttf in resourse and use every time when you want to display formatted font like
在您的资源目录中添加一个字体,就像您已经完成的此图像一样,现在主要的事情是您无法写入您添加的字体的名称,因为它检查我的图像字体名称为 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.
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];