Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS - Background color for UITableController section footer

Can anyone enlighten me on how to make the uitableview footer have a clear background?

I have added a 15 height footer which is added via the following -

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section==0){
        return 0;
    }
    else{
        return  15;
    }
}

that works fine - but the footer is a grey strip - the tableview has a background image - so i'd like the footer to be clear - is this possible? if so how do i style it?

like image 474
Dancer Avatar asked Mar 22 '26 17:03

Dancer


2 Answers

We have a better solution for this from iOS6 onwards:

There is a delegate method - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);

You can use this method like this

- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section {

    //Set the background color of the View
    view.tintColor = [UIColor blueColor];

    //Set the TextLabel Color
    UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
    [header.textLabel setTextColor:[UIColor whiteColor]];
}
like image 80
Augustine Avatar answered Mar 24 '26 10:03

Augustine


Implement the - (UIView *)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section delegate and return a UIView in it with clear background. You could also try setting the [self.table setTableFooterView:nil] That should solve the issue.

like image 30
batman Avatar answered Mar 24 '26 08:03

batman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!