2011-01-18 4 views
0

titleForHeaderInSection 안에있는 글꼴 색을 변경하는 방법 ??캔트 변경 아이폰의 titleForHeaderInSection 안에있는 글꼴 색

- (NSString *)tableView:(UITableView *)tblView titleForHeaderInSection:(NSInteger)section { 


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


    //tabelView.backgroundColor = [UIColor blueColor]; 






    NSString *sectionName = nil; 

    switch(section) 
    { 
     case 0: 
      NSLog(@"ok"); 


      UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,100,30)]; 

      myLabel.font = [UIFont fontWithName:@"Zapfino" size: 14.0]; 
      myLabel.shadowColor = [UIColor grayColor]; 
      myLabel.shadowOffset = CGSizeMake(1,1); 
      myLabel.textColor = [UIColor redColor]; 

      myLabel.backgroundColor = [UIColor clearColor]; 

      myLabel.text = @"DESCRIPTION";// not working i can only see value no color no font 
    } 
    } 

답변

1

내가이

(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
return 44.0; 
} 
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
// create the parent view that will hold header Label 
UIView* customView = [[[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 150.0, 44.0)]autorelease]; 






NSString *sectionName = nil; 

switch(section) 
{ 
case 0: 

if(counter<=3) 
NSLog(@"ok"); 

// create the buNSLog(@"ok");tton object 
UILabel * headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero]autorelease] ; 
headerLabel.backgroundColor = [UIColor clearColor]; 
headerLabel.opaque = NO; 
headerLabel.textColor = [UIColor whiteColor]; 
headerLabel.highlightedTextColor = [UIColor whiteColor]; 
headerLabel.font = [UIFont boldSystemFontOfSize:20]; 
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 44.0); 

// If you want to align the header text as centered 
// headerLabel.frame = CGRectMake(150.0, 0.0, 300.0, 44.0); 

headerLabel.text = @"Description"; // i.e. array element 
[customView addSubview:headerLabel]; 


if(counter==7) 

headerLabel.text = @""; // i.e. array element 
[customView addSubview:headerLabel]; 

//sectionName = @"DES-"; 

break; 

case 1: 

감사처럼했다

1
#pragma mark - 
#pragma mark Table View Delegate Methods 
- (UIView *)tableView:(UITableView *)tableView 
viewForHeaderInSection:(NSInteger)section { 
UILabel *sectionHeader = [[[UILabel alloc] initWithFrame:CGRectNull] autorelease]; 
sectionHeader.backgroundColor = [UIColor groupTableViewBackgroundColor]; 
sectionHeader.textAlignment = UITextAlignmentCenter; 
sectionHeader.font = [UIFont boldSystemFontOfSize:16]; 
sectionHeader.textColor = [UIColor blueColor]; 
sectionHeader.text = [NSString stringWithFormat:@"Section %d", section]; 
return sectionHeader; 
} 
- (CGFloat)tableView:(UITableView *)tableView 
heightForHeaderInSection:(NSInteger)section { 
return 40; 
}