2014-07-17 127 views
0

我有一个带有字体的自定义按钮。删除UIButton标题

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

但是,上面的文字似乎是“切断”一点。看到“S”的顶部。

enter image description here

我不想改变按钮的框架中,font.Changing插图不列入避免问题的大小。这是模拟器错误还是helvetica字体问题?任何工作?

+0

可能重复时sizeToFit是文本所谓](http://stackoverflow.com/questions/20978640/uibutton-does-not-resize-height-correctly-with-custom-font-when-sizetofit-is-cal) – rishi

+1

你也可以看看这个[链接](http://stackoverflow.com/questions/10200032/cropped-uibutton-title/10200908#10200908) – rishi

回答

0

集UIButton的标题到零,然后用文本创建标签,并添加子视图这就是UIButton的一切,现在会正确显示,你需要的[UIButton的不与自定义字体正确地调整高度