0

I have a custom button with the font.

customButtonSynchronize = [UIButton buttonWithType:UIButtonTypeCustom];
customButtonSynchronize.frame=CGRectMake(578, 27.5, 91, 29) ;
[customButtonSynchronize setBackgroundImage:[UIImage imageNamed:@"synchronize.png"]
                                   forState:UIControlStateNormal];
customButtonSynchronize.titleLabel.font = [UIFont fontWithName:@"HelveticaLTStd-Roman" size:14.0f];
[customButtonSynchronize setTitle:@"Sincronizzare" forState:UIControlStateNormal];
/////HERE//////////
customButtonSynchronize.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
customButtonSynchronize.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
customButtonSynchronize.contentEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
customButtonSynchronize.backgroundColor=[UIColor clearColor];
[customButtonSynchronize addTarget:self action:@selector(synchronizeDB:) forControlEvents:UIControlEventTouchUpInside];

But the text above seems to be "Cut off" a little.See the top of "S".

enter image description here

I dont want to change frame of button,size of the font.Changing the inset DOESNOT avoid the problem. Is it a simulator bug or problem with helvetica font? Any work around?

VARUN ISAC
  • 443
  • 3
  • 13
  • possible duplicate of [UIButton does not resize height correctly with custom font when sizeToFit is called](http://stackoverflow.com/questions/20978640/uibutton-does-not-resize-height-correctly-with-custom-font-when-sizetofit-is-cal) – rishi Jul 17 '14 at 03:34
  • 1
    You can also take a look at this [Link](http://stackoverflow.com/questions/10200032/cropped-uibutton-title/10200908#10200908) – rishi Jul 17 '14 at 03:34

1 Answers1

1

set uibutton title to nil then create label with text and add subview to uibutton thats all, now it will display text correctly as you required

falcon143
  • 702
  • 4
  • 19