I need to change the co9lor of title of UITable section. Help need urgrntly
+1
A:
Use - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
This method is part of UITableViewDelegate
Return the view with label. you can now configure label color.
Satyam svv
2010-09-15 07:32:50
Hi Satyam I used this method and it worked for me.
Harsh
2010-09-24 06:55:56
+1
A:
Use the below code for your answer
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *tempView=[[[UIView alloc]initWithFrame:CGRectMake(0,0,300,44)]autorelease];
tempView.backgroundColor=[UIColor redColor];
UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,300,44)];
tempLabel.backgroundColor=[UIColor clearColor];
tempLabel.text=@"MY HEADER";
[tempView addSubView: tempLabel];
[tempLabel release];
return tempView;
}
This will give you a redColor header. Change the color as per your requirement...
Edited (as per Harsh):
Since the view in header will overlap your First cell so increase the height of the header
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50;
}
hAPPY cODING...
Suriya
2010-09-15 08:30:05
thanks zem for pointing out.. As i have wriiten the code directly over here so have forgot. Also Please set the frames as per your convinience...
Suriya
2010-09-15 08:36:35
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 50;}
Harsh
2010-09-21 10:22:07
Thanks Suriya but I found that one should also use ablove function to set the height of the section header otheraise the header name will be overlapped with the table cell.
Harsh
2010-09-21 10:23:14
Yes the height must be greater than the views size..I have edited and added that too in the answer `Getting a vote is the best thanks...`
Suriya
2010-09-21 11:17:35