Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom font on UIbutton title clipped on top of word

Tags:

I have uploaded a custom font and applied this font on the title of a UIbutton using the following code

videoButton.titleLabel.font = [UIFont fontWithName:@"LaurenScript" size:20]; 

The problem is that the title is being clipped on the top of the first letter (see photo below). I tried the same font on the UIlabel and it works fine so it is not a problem with the font. I tried also to change the rectFrame using

[videoButton.titleLabel setFrame:CGRectMake(0, 0, 300, 600)]; 

but that didn't do anything. Has anybody a clue of how I can fix this problem? Cheers

enter image description here

like image 766
Cyril Gaillard Avatar asked Nov 05 '12 04:11

Cyril Gaillard


2 Answers

I had a similar problem, where a diaeresis got cut off on top of the titlelabel. I made a UIButton subclass and used this code to fix the problem:

-(void)layoutSubviews {     [super layoutSubviews];      CGRect frame = self.titleLabel.frame;     frame.size.height = self.bounds.size.height;     frame.origin.y = self.titleEdgeInsets.top;     self.titleLabel.frame = frame; } 
like image 119
Antoine Avatar answered Oct 22 '22 15:10

Antoine


Select button in Interface builder and check for set a vertical alignment panel in the control section Below is example:

enter image description here

like image 39
Hardik Darji Avatar answered Oct 22 '22 15:10

Hardik Darji