开发者

is there somebody who made an application using background for tableview and tableviewcell?

like my question, i just want to ask somebody who made an application that use background for his/her tableview and tableviewcell. Cause i have a problem with those background. Here is my app pic with the problem

is there somebody who made an application using background for tableview and tableviewcell?

i use graycolor for background in tableview and whitecolor for background in tableviewcell, i want to make all cell that containt a text have a whitecolor background, but i can't do it. here's my code

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
UIView* backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ];

//--new color code--
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"celltable_root.png"]];

cell.backgroundView = backgroundView;
for ( UIView* view in cell.contentView.subviews ) 
{
    if(_segmentedControl.selectedSegmentIndex == 0){
        FileModel *filemodels = [_filemodels objectAtIndex:indexPath.row];
        if([filemodels.fileExpanse compare:@"display"]==0){

            backgroundView.backgroundColor = [UIColor whiteColor];


        }else{
            backgroundView.backgroundC开发者_Go百科olor = [UIColor whiteColor];

        }
    }

    view.backgroundColor = [ UIColor clearColor]; //set cell background

}

    [[self tableView] setBackgroundColor:[UIColor grayColor]]; 

}

is there something wrong in my code??


i already read the link that Derek gave to me, and i found a code that i can use. I've decided to use image for cell background and table background. and this is my code to answer this question

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    if(_segmentedControl.selectedSegmentIndex == 0){
        FileModel *filemodels = [_filemodels objectAtIndex:indexPath.row];
        if([filemodels.fileExpanse compare:@"display"]==0){

            ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"whiteColor.png"];

        }else{
            ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"whiteColor.png"];

        }
    }

    [[self tableView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"grayColor.png"]]]; //tableview background using image

}

and i added

[[self tableView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"grayColor.png"]]]; //tableview background using image

into viewDidLoad method, and finally...this problem is solved. Thx everyone... (n_n)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜