2010-12-19 75 views
4

我怎樣才能按鈕標籤的字體設置爲世紀的哥特式粗體大小46 我使用下面的代碼:iphone - 集標籤字體

 [self.titleLabel setFont:[UIFont fontWithName:@"Century Gothic-Bold" size:46]]; 

是我的代碼正確與否?

回答

1

我昨天用這個:

onlineButton.titleLabel.font = [UIFont boldSystemFontOfSize:onlineButton.titleLabel.font.pointSize+3]; 

那麼試試這個:

yourButton.titleLabel.font = [UIFont fontWithName:fontName size:size]; 
+0

你的方式和我的實施方式是正確的。但我想知道是否使用我的代碼中提到的字體名稱是否正確...... – Satyam 2010-12-20 09:16:04

4
UIButton *NameBtn=[UIButton buttonWithType:UIButtonTypeCustom]; 
    NameBtn=[[UIButton alloc]init]; 
    [NameBtn setBackgroundColor:[UIColor clearColor]]; 
    [NameBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
    NSString *textb=[[self.searchList objectAtIndex:indexPath.row] objectForKey:@"name"]; 
    CGSize constraintb = CGSizeMake(310 ,10); 
    CGSize sizeb = [textb sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:constraintb lineBreakMode:UILineBreakModeWordWrap]; 
    [NameBtn setTitle:textb forState:UIControlStateNormal]; 
    NameBtn.font = [UIFont fontWithName:@"Helvetica-Bold" size: 12.0]; 
    NameBtn.frame = CGRectMake(85, 12, MAX(sizeb.width ,3.0f),12); 
    [NameBtn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 
    NameBtn.tag=indexPath.row; 

    [self.view addSubview:NameBtn];