美文网首页
tableView:viewForHeaderInSection

tableView:viewForHeaderInSection

作者: 张嘉夫 | 来源:发表于2016-08-24 18:50 被阅读104次
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    float width = tableView.bounds.size.width;
    int fontSize = 18;
    int padding = 10;

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, fontSize)];
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    view.userInteractionEnabled = YES;
    view.tag = section;

    UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlainTableViewSectionHeader.png"]];
    image.contentMode = UIViewContentModeScaleAspectFit;

    [view image];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(padding, 2, width - padding, fontSize)];
    label.text = @"Texto";
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor whiteColor];
    label.shadowColor = [UIColor darkGrayColor];
    label.shadowOffset = CGSizeMake(0,1);
    label.font = [UIFont boldSystemFontOfSize:fontSize];

    [view addSubview:label];

    return view;
}

相关文章

网友评论

      本文标题:tableView:viewForHeaderInSection

      本文链接:https://www.haomeiwen.com/subject/bysosttx.html