2012-06-29 165 views
3

此代碼似乎工作正常,修改我的按鈕的屬性,但titleLabel字體顏色不變。我可以更改字體,字體大小,陰影而不是顏色。它目前顯示爲白色,但我試圖將其設置爲黑色。我試過button1.titleLabel.textColor = [UIColor blackColor];和[button1.titleLabel setTextColor:[UIColor blackColor]];似乎承認財產,但仍然是白色的。如何更改titleLabel字體顏色,Xcode

[button1.titleLabel setTextColor:[UIColor blackColor]];   
[button1.titleLabel setFont:[UIFont boldSystemFontOfSize:20]]; 
[button1.titleLabel setShadowColor:[UIColor blackColor]]; 
[button1.titleLabel setShadowOffset:CGSizeMake(-1, 1)]; 
[button1 setTitle:@"Do it" forState:UIControlStateNormal]; 
button1.frame = CGRectMake(0, 0, 250, 40.0); 
[myView addSubview:button1]; 

回答

17

這工作。

[button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
+0

EmptyStack回答了這一點,謝謝! – Mrwolfy