UITableView自定义Section

- (UIView *)tableView:(UITableView *)tableView 

viewForHeaderInSection:(NSInteger)section

{

    UIView *headerView = [[UIViewalloc] initWithFrame:CGRectMake(10, 0, 300, 30)];//创建一个视图  

    UIImageView *headerImageView = [[UIImageViewalloc] initWithFrame:CGRectMake(10, 0, 300, 30)];

    UIImage *image = [UIImageimageNamed:@"4-2.png"];

    [headerImageView setImage:image];

    [headerView addSubview:headerImageView];

    [headerImageView release];

    UILabel *headerLabel = [[UILabelalloc] initWithFrame:CGRectMake(130, 5, 150, 20)];

    headerLabel.backgroundColor = [UIColorclearColor];

    headerLabel.font = [UIFontboldSystemFontOfSize:15.0];

    headerLabel.textColor = [UIColorblueColor];

    headerLabel.text = @"Section";

    [headerView addSubview:headerLabel];

    [headerLabel release];

    

    return headerView;

}//自定义section的头部

posted @ 2012-05-22 15:16  hellocby  阅读(4045)  评论(0编辑  收藏  举报