customize UITableView Header Section at run time

Hic Up

I have set header back ground using the code below but I want to change the color of header back again on run time when I click on the button that is added as a subview on the header. please provide me code, thanks in advance :)

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

    header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _tableView.bounds.size.width, 50)];
 header.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"homeCellHeaderBackGround.png"]];

    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 30)];
    label.text = _array[section][@"name"];
    label.textColor = [UIColor whiteColor];


    [header addSubview:label];


    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(230, 10, 70, 35)];
    [button addTarget:self action:@selector(onExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    //[button setTitle:@"Expand" forState:UIControlStateNormal];
    [button setTag:section];

    [header addSubview:button];

    return header;
}
kslcam

You can change the background color of the section header by following code:

- (IBAction)onExpandButton:(id)sender {
   UIView *header = ((UIButton *)sender).superView;
   header.backgroundColor = <Whatever UIColor you like>;
   ...
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

iOS Customize UItableView header

From Dev

UITableView Section Header not showing

From Dev

How to pad a UITableView section header?

From Dev

UITableView section header inset missing

From Dev

Adding UIButton to UITableView section header

From Dev

Set color of UITableView Section Header

From Dev

Section Header Not Showing in Programmatic UITableView

From Dev

Uneven section header size in static UITableView

From Dev

Section header cannot be hidden in UITableView with UITableViewAutomaticDimension

From Dev

How to add a UISegmentedControl to Section header of UITableView with margin?

From Dev

UITableview refreshing cells scrolling under section header

From Dev

Design UITableView's section header in Interface Builder

From Dev

iOS UITableView showing section header programmatically

From Dev

UITableView & Sections - to detect if a section header is stays on top

From Dev

How to add a UISegmentedControl to Section header of UITableView with margin?

From Dev

How to make the first row of an UITableView a header of a section?

From Dev

Section header cannot be hidden in UITableView with UITableViewAutomaticDimension

From Dev

UITableView section header floating after changing tab

From Dev

UITableView section header does not always draw

From Dev

UITableView section header appearing over table header view

From Dev

Dynamic UITableView header (not section header) auto layout problems

From Dev

Customize a table view section header in a storyboard rather than programmatically?

From Dev

How to know what a tap has been made on a header section of a UITableView?

From Dev

Unexpected Header View in UITableView's section using NSFetchedResultsController

From Dev

Stop transparent UITableView section header from flashing when reloading

From Java

How to hide first section header in UITableView (grouped style)

From Dev

Show Selection Highlight on UITableView Section Header When Touched

From Dev

Header/Footer height of a UITableView section based on title text height

From Dev

UITableView embedded in other view has wrong position of section header

Related Related

  1. 1

    iOS Customize UItableView header

  2. 2

    UITableView Section Header not showing

  3. 3

    How to pad a UITableView section header?

  4. 4

    UITableView section header inset missing

  5. 5

    Adding UIButton to UITableView section header

  6. 6

    Set color of UITableView Section Header

  7. 7

    Section Header Not Showing in Programmatic UITableView

  8. 8

    Uneven section header size in static UITableView

  9. 9

    Section header cannot be hidden in UITableView with UITableViewAutomaticDimension

  10. 10

    How to add a UISegmentedControl to Section header of UITableView with margin?

  11. 11

    UITableview refreshing cells scrolling under section header

  12. 12

    Design UITableView's section header in Interface Builder

  13. 13

    iOS UITableView showing section header programmatically

  14. 14

    UITableView & Sections - to detect if a section header is stays on top

  15. 15

    How to add a UISegmentedControl to Section header of UITableView with margin?

  16. 16

    How to make the first row of an UITableView a header of a section?

  17. 17

    Section header cannot be hidden in UITableView with UITableViewAutomaticDimension

  18. 18

    UITableView section header floating after changing tab

  19. 19

    UITableView section header does not always draw

  20. 20

    UITableView section header appearing over table header view

  21. 21

    Dynamic UITableView header (not section header) auto layout problems

  22. 22

    Customize a table view section header in a storyboard rather than programmatically?

  23. 23

    How to know what a tap has been made on a header section of a UITableView?

  24. 24

    Unexpected Header View in UITableView's section using NSFetchedResultsController

  25. 25

    Stop transparent UITableView section header from flashing when reloading

  26. 26

    How to hide first section header in UITableView (grouped style)

  27. 27

    Show Selection Highlight on UITableView Section Header When Touched

  28. 28

    Header/Footer height of a UITableView section based on title text height

  29. 29

    UITableView embedded in other view has wrong position of section header

HotTag

Archive