Iphone - set label font

How to set the button label font on a Century Gothic Bold size of 46. I use the following code:

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

Is my code correct or not?

+4
source share
3 answers

I think iOS does not support your font. But there is an AppleGothic font.

see this link

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

+2
source
  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]; 
+4
source

I used yesterday:

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

So try the following:

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

Source: https://habr.com/ru/post/1332642/


All Articles