UITableView自定义Section
//创建view来添加标题 section的头部
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 82, 50)] autorelease];
view.backgroundColor = [UIColor clearColor];
view.userInteractionEnabled=NO;
UILabel *textLabel = [[[UILabel alloc] initWithFrame:CGRectMake(20, 0, 70, 20)] autorelease];
textLabel.backgroundColor=[UIColor clearColor];
textLabel.textColor = [UIColor redColor];
textLabel.font=[UIFont systemFontOfSize:14];
textLabel.shadowColor=[UIColor whiteColor];
textLabel.shadowOffset=CGSizeMake(0,1);
[view addSubview:textLabel];
switch (section) {
case 0:
textLabel.text = @"基础信息";
break;
case 1:
textLabel.text = @"状态信息";
break;
default:
break;
}
NSString *_imageViewPath = [[[NSBundle mainBundle] pathForResource:@"niutou" ofType:@"jpg"] autorelease];
UIImage *_imageViewImage = [UIImage imageWithContentsOfFile:_imageViewPath];
UIImageView *_imageView = [[[UIImageView alloc] init] autorelease];
_imageView.image = _imageViewImage;
_imageView.frame = CGRectMake(0, 2, 30, 40);
[view addSubview:_imageView];
return view;
}//自定义section的头部