2011-07-29 38 views
3

我正在更改UIButton字體大小,但它不起作用。UIButton字體大小不變

UIButton*headingButton=[UIButton buttonWithType:UIButtonTypeCustom]; 

headingButton.frame=CGRectMake(182, 4, 450, 42);   

[headingButton setTitleColor:[UIColor colorWithRed:36/255.0 green:71/255.0 blue:113/255.0 alpha:1.0] forState:UIControlStateNormal]; 

回答

5

我不能在此代碼,美正在改變字體大小,但無論如何看,這是可以做到像這樣:

[headingButton.titleLabel setFont:[UIFont fontWithName:<your font name> size:<your desired size>]]; 

[headingButton.titleLabel setFont:[UIFont fontWithName:systemFontOfSize:<your desired size>]]; 

更新:另外你還需要看看你的字體是否設置存在你的應用程序檢查只是這樣做:

NSLog(@"Font family names: %@", [UIFont familyNames]); 
NSLog(@"Fonts in family Myriad Pro : %@", [UIFont fontNamesForFamilyName:@"Myriad Pro"]); 

如果它不存在,則需要將OTF文件拖放到烏爾項目,也可以添加在info.plist中

+0

[headingButton.titleLabel.setFont = [UIFont fontWithName:@「Myriad Pro Bold」size:24]]; – Ali

+0

我已經嘗試過這樣但不工作 – Ali

+0

這不是正確的格式。使用[headingButton.titleLabel setFont:[UIFont fontWithName:@「Myriad Pro Bold」size:24]];如果這不是你的問題,請參閱我的編輯 –

0
btn.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:8.0]; 

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

第一行中的「通過應用程序提供的字體」設置字體名稱和大小和第二線粗體字體