2013-12-19 22 views
0

TableView中頁腳我有一個按鈕titleLabel.textColor爲UIButton的

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
    UIView *mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 39)]; 
    [mainView setBackgroundColor:[UIColor clearColor]]; 
    UIButton *themebutton= [UIButton buttonWithType:UIButtonTypeCustom]; 
    themebutton.backgroundColor= [UIColor redColor]; 
    [themebutton.layer setCornerRadius:5.8f]; 
    themebutton.frame= CGRectMake(15, 0, 172, 39); 
    [themebutton setTitle:@"Create New" forState:UIControlStateNormal]; 
    [themebutton setTitle:@"Create New" forState:UIControlStateSelected]; 
    [themebutton setTitle:@"Create New" forState:UIControlStateHighlighted]; 
    themebutton.titleLabel.font=[UIFont fontWithName:@"Raleway" size:19.8]; 

    themebutton.titleLabel.textColor=UIColorFromRGB(0x707070); 

    [mainView addSubview:themebutton]; 
    return mainView; 
} 

我已經把titleLabel.textColor爲灰色,但是當我點擊該按鈕,它總是文字的顏色轉換成白光。爲什麼這種情況會有人幫助我。

回答

7

您需要設置取決於國家的顏色,例如:

[themebutton setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 
[themebutton setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted]; 

這將顯示標籤紅色,按​​下時會變成綠色。