带有背景图像的 UITableView 单元格 [英] UITableView cell with background image

查看:34
本文介绍了带有背景图像的 UITableView 单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableView,里面有 3 张图片.1 表示选中的 Cell,1 表示 Cell 背景,1 表示 TableView 背景.

i have a UITableView, where theres 3 images. 1 for the selected Cell, 1 for the Cell background, and 1 for the TableView background.

我选择的单元格工作正常,但正常单元格和 TableView 背景(向下/向上滚动时单元格后面的背景)有一些问题

My selected Cell, is working just fine, but have some problems with the normal cells, and the TableView background(the background behind the cells when you scroll down/up to much)

有人可以帮我设置每个单元格的背景和 TableView 背景吗?这是怎么做的?

Can some one help me with a background for each cell, and a TableView background ? how is this done ?

正常单元格背景:(不确定是否正确)

Normal Cell background: (not sure if its right)

// CELL'S BACKGROUND-IMAGE
    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]];

选定的单元格背景:

// SELECTED CELL'S BACKGROUND-IMAGE
    UIView *viewSelected = [[[UIView alloc] init] autorelease];
    viewSelected.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"cell_highlighted.PNG"]];
    cell.selectedBackgroundView = viewSelected;

推荐答案

For Cell

    cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cell_normal.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];  
    cell.selectedBackgroundView =  [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cell_pressed.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];

对于 Tableview

For Tableview

    [mEditTableView setBackgroundView:nil];
    [mEditTableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"apple.png"]] ];

这篇关于带有背景图像的 UITableView 单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆