您的位置:首页 > 产品设计 > UI/UE

iOS开发经验总结:自定义UITableView

2012-12-05 10:19 489 查看
一、自定义UITableView hearder

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

UIView *v_headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 23)];//创建一个视图(v_headerView)

UIImageView *v_headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 23)];//创建一个UIimageView(v_headerImageView)

v_headerImageView.image = [UIImage imageNamed:@"ip_top bar.png"];//给v_headerImageView设置图片

[v_headerView addSubview:v_headerImageView];//将v_headerImageView添加到创建的视图(v_headerView)中

[v_headerImageView release];//释放v_headerImageView所占用的资源

UILabel *v_headerLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 1, 100, 19)];//创建一个UILable(v_headerLab)用来显示标题

v_headerLab.backgroundColor = [UIColor clearColor];//设置v_headerLab的背景颜色

v_headerLab.textColor = [UIColor grayColor];//设置v_headerLab的字体颜色

v_headerLab.font = [UIFont fontWithName:@"Arial" size:13];//设置v_headerLab的字体样式和大小

v_headerLab.shadowColor = [UIColor whiteColor];//设置v_headerLab的字体的投影

[v_headerLab setShadowOffset:CGSizeMake(0, 1)];//设置v_headerLab的字体投影的位置

//设置每组的的标题

if (section == 0) {

v_headerLab.text = @"拍品导航";

}

if (section == 1) {

v_headerLab.text = @"专场特卖";

}

[v_headerView addSubview:v_headerLab];//将标题v_headerLab添加到创建的视图(v_headerView)中

[v_headerLab release];//释放v_headerLab所占用的资源

return v_headerView;//将视图(v_headerView)返回

}

http://www.cocoachina.com/bbs/read.php?tid-12269.html
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: