10

仔细看下面的代码。因为它完美地工作。尝试添加到您的应用程序中。它会起作用的

- (void)viewDidLoad {
[super viewDidLoad];
// title label - tip
UILabel *tmp=[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 200, 200)]; 
tmp.textColor=[UIColor colorWithRed:(14.0/255.0) green:(105.0/255) blue:(128.0/255) alpha:1.0];
[tmp setFont:[UIFont fontWithName:@"Arial" size:18]]; tmp.text=@"sagar";
tmp.backgroundColor=[UIColor clearColor]; [self.view addSubview:tmp]; [tmp release];
}

现在,请仔细查看以下代码。因为它不起作用。看看这两个代码之间没有什么区别。

- (void)viewDidLoad {
[super viewDidLoad];
// title label - tip
UILabel *tmp=[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 200, 200)]; 
tmp.textColor=[UIColor colorWithRed:(14.0/255.0) green:(105.0/255) blue:(128.0/255) alpha:1.0];
[tmp setFont:[UIFont fontWithName:@"Arial Black" size:18]]; tmp.text=@"sagar";
tmp.backgroundColor=[UIColor clearColor]; [self.view addSubview:tmp]; [tmp release];
}

我刚刚提到了#Arial Black# 而不是#Arial#。

  • 但是它不起作用。
  • 是因为 iPhone 不支持 =Arial Black= 吗?

我想知道为什么它不起作用。

iPhone 支持多少种不同的字体?

有清单吗?

如何将字体名称设置为 UILabel 或任何控件?(字体名称中有空格)

提前感谢您与我分享您的知识。

4

3 回答 3

22

是 iPhone OS 中可用的字体列表。Arial Black 似乎不在其中。

于 2009-09-04T17:14:47.423 回答
12

尝试@"Arial-BoldMT"

此外,您可以随时为自己列出可用字体列表:

for( NSString *familyName in [UIFont familyNames] ) {
  for( NSString *fontName in [UIFont fontNamesForFamilyName:familyName] ) {
    NSLog(@"%@", fontName);
  }
}
于 2009-09-04T17:26:44.530 回答
0

App Store 中有很多字体应用程序可以查看所有字体 - 其中一个是iFonts,这是我开发的一个应用程序,因此我可以将字体列表通过电子邮件发送给团队中的其他人。

于 2011-06-20T09:20:46.963 回答