Ron*_*Ron 0 uibutton uitableview ios
在tableView页脚中,我有一个按钮
-(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设置为灰色,但是当我点击该按钮时,它总是将文本颜色转换为白色.为什么会发生这种事情可以帮助我.
您需要根据状态设置颜色,例如:
[themebutton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[themebutton setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
这将显示红色标签,按下时会变为绿色.
| 归档时间: | 
 | 
| 查看次数: | 712 次 | 
| 最近记录: |