如何在InAppSettingsKit类中更改标题部分文本颜色?

时间:2011-04-18 01:14:18

标签: ios iphone cocoa-touch uitableview inappsettingskit

我正在为我的应用程序使用InAppSettingsKit,但是我在分组的tableview中更改我的节标题的文本颜色时遇到了问题。我尝试使用以下代码,但它不起作用:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,200,300,244)];
        tempView.backgroundColor=[UIColor clearColor];

        UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0,300,44)];
        tempLabel.backgroundColor=[UIColor clearColor]; 
        tempLabel.shadowColor = [UIColor blackColor];
        tempLabel.shadowOffset = CGSizeMake(0,2);
        tempLabel.textColor = [UIColor redColor]; //here u can change the text color of header
        tempLabel.font = [UIFont fontWithName:@"Helvetica" size:fontSizeForHeaders];
        tempLabel.font = [UIFont boldSystemFontOfSize:fontSizeForHeaders];
            tempLabel.text=@"Header Text";

        [tempView addSubview:tempLabel];

        [tempLabel release];
        return tempView;
    }

InAppSettingsKit代码如下所示:

- (NSString *)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section {
    NSString *header = [self.settingsReader titleForSection:section];
    if (0 == header.length) {
        return nil;
    }
    return header;
}

- (UIView *)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {
    NSString *key  = [self.settingsReader keyForSection:section];
    if ([self.delegate respondsToSelector:@selector(tableView:viewForHeaderForKey:)]) {
        return [self.delegate tableView:_tableView viewForHeaderForKey:key];
    } else {
        return nil;

}
}

我如何在代码中实现第一个代码?我需要更改这些标题的文字颜色。感谢。

1 个答案:

答案 0 :(得分:1)

-tableView:viewForHeaderForKey:中实施IASKSettingsDelegate。实施方式与您的-tableView:viewForHeaderInSection:代码相同,只是您需要检查key以确定标签的文本(如果您有多个标头)。