与背景图像的UITableView细胞 [英] UITableView cell with background image

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

问题描述

我有一个UITableView,在那里有3幅图像。
1所选择的细胞,1为细胞背景,和1对的TableView背景

我选中的单元格,工作得很好,但有一些问题与正常细胞和背景的TableView(单元后面的背景,当你向下滚动/不怎么样)

能有人帮助我与每个小区的背景,和一个TableView中的背景?这是怎么做的?

正常细胞背景:(不知道其右)

  //单元格的背景图片
    self.tableView.backgroundColor = [的UIColor colorWithPatternImage:[UIImage的imageNamed:@cell_normal.PNG]];

选定单元格背景:

  //选定单元格的背景-IMAGE
    UIView的* viewSelected = [[[UIView的页头] INIT]自动释放];
    viewSelected.backgroundColor = [的UIColor colorWithPatternImage:[UIImage的imageNamed:@cell_highlighted.PNG]];
    cell.selectedBackgroundView = viewSelected;


解决方案

有关细胞

  cell.backgroundView = [[UIImageView的页头] initWithImage:[UIImage的imageNamed:@cell_normal.png] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0];
    cell.selectedBackgroundView = [[UIImageView的页头] initWithImage:[UIImage的imageNamed:@cell_ pressed.png] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0];

有关泰伯维

  [mEditTableView setBackgroundView:无];
    [mEditTableView setBackgroundView:[​​[UIImageView的页头] initWithImage:[UIImage的imageNamed:@apple.png]]];

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

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)

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 Background:

// 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] ];

For Tableview

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

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

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