IPhone header and footer text

I have a question about printing text in the header and footer of a table. I want to show some text in the footer of each line, but I have a problem with this. When I start the next section, he starts to draw from the bottom of the first. To get an idea of ​​what I need, go to Settings-> General-> Network

On this screen, we have several sections, and after the first two sections we have information about the footer.

Please check this out on the iPhone 3G. (I'm not sure if this screen is available for other iPhone options.)

Let me know if you need clarification in the description.


Here is an implementation of two functions, but it is not displayed as desired

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
      if (section == 1)
      {
        CGRect rect = CGRectMake(10.0f,40.0f,300.0f,250.0f);

        UILabel* label  = [[[UILabel alloc] initWithFrame:rect] autorelease];
        label.backgroundColor   = [UIColor clearColor];
            label.text      = NSLocalizedString(@"MessageHeader","");;
            label.baselineAdjustment= UIBaselineAdjustmentAlignCenters;
            label.lineBreakMode =  UILineBreakModeWordWrap;
            label.textAlignment = UITextAlignmentCenter;
            label.shadowColor   = [UIColor whiteColor];
            label.shadowOffset  = CGSizeMake(0.0, 1.0);
            label.font      = [UIFont systemFontOfSize:14];
            label.textColor     = [UIColor darkGrayColor];
            label.numberOfLines = 0;


            UIView *view = [[[UIView alloc] initWithFrame:rect] autorelease];

            [view addSubview:label];

            return view;
        }
    }   
    return nil;     
}


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

   if (section == 1) 
   {
                          CGRect rect       = CGRectMake(10.0f,80.0f,300.0f,250.0f); 

                         UILabel* label = [[[UILabel alloc] initWithFrame:rect] autorelease];
                      label.backgroundColor = [UIColor clearColor];
                      label.text        = NSLocalizedString(@"MessageFooter","");
                      label.baselineAdjustment= UIBaselineAdjustmentAlignCenters;
            label.lineBreakMode     =  UILineBreakModeWordWrap;
            label.textAlignment     = UITextAlignmentCenter;
            label.shadowColor       = [UIColor whiteColor];
            label.shadowOffset      = CGSizeMake(0.0, 1.0);
            label.font          = [UIFont systemFontOfSize:14];
            label.textColor         = [UIColor darkGrayColor];
            label.numberOfLines = 0;
            UIView *view = [[[UIView alloc] initWithFrame:rect] autorelease];
            [view addSubview:label];

            return view;
        }
    }
    return nil;
}

? .

+3

Source: https://habr.com/ru/post/1720576/


All Articles