开发者

Grouped UITableViewCell with transparent background image

I'm trying to give the cells in my grouped UITableView a semi-transparent image as the开发者_开发技巧ir background. I've tried so many different ways but can't seem to get it to work. This is what I've got so far:

-(void) viewWillAppear:(BOOL) animated{
[super viewWillAppear:animated];
self.table.backgroundColor = [UIColor clearColor];}

.

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{


UIImage *cellBackground;
NSInteger sectionRows = [tableView numberOfRowsInSection:[indexPath section]];
NSInteger row = [indexPath row];


if (row == 0)
{
    cellBackground = [UIImage imageNamed:@"tCT.png"];
}

else if (row == sectionRows -1)
{
    cellBackground = [UIImage imageNamed:@"tableCellBottom.png"];
}

else
{
    cellBackground = [UIImage imageNamed:@"tableCellMiddle.png"];
}

cell.backgroundColor = [UIColor clearColor];
UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
cellBackView.backgroundColor = [UIColor colorWithPatternImage: cellBackground];
cell.backgroundView = cellBackView; 

So at the moment the image shows up, but it's transparency isn't obvious. The background is a solid grey (rather than a semi-transparent grey). There are also black corners on the rounded group-table corners.

Any idea where I'm going wrong?


set the backgroundColor of your cell's contentView to clearColor to remove the black borders.

self.contentView.backgroundColor = [UIColor clearColor];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜