Satyam
Satyam

Reputation: 15894

iphone - set label font

How can I set the font of button label to Century Gothic Bold of size 46. I'm using following code:

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

Is my code correct or not?

Upvotes: 4

Views: 15244

Answers (3)

Nithin M Keloth
Nithin M Keloth

Reputation: 1595

 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];

Upvotes: 4

Fabio Poloni
Fabio Poloni

Reputation: 8371

I used yesterday this:

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

So try this:

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

Upvotes: 1

ipraba
ipraba

Reputation: 16543

I think iOS doesnt support your font. But there is a font called AppleGothic.

see this link

http://www.prepressure.com/fonts/basics/ios-4-fonts

Upvotes: 2

Related Questions