简体   繁体   中英

How to change header section text color in InAppSettingsKit class?

I'm using InAppSettingsKit for my app but I'm having problems changing the text color of my section headers in my grouped tableview. I've tried using the following code but it doesn't work:

-(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;
    }

The InAppSettingsKit code looks like so:

- (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;

}
}

How would I implement the first code into their code? I need to change the text color of those titles. Thanks.

Implement -tableView:viewForHeaderForKey: in your IASKSettingsDelegate . The implementation would be identical to your -tableView:viewForHeaderInSection: code except that you'd need to check the key to determine the text of the label (if you have multiple headers).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM