簡體   English   中英

將UITableViewCell分組為透明背景圖像

[英]Grouped UITableViewCell with transparent background image

我正在嘗試為分組的UITableView中的單元格提供半透明的圖像作為背景。 我嘗試了許多不同的方法,但似乎無法使其正常工作。 到目前為止,這是我得到的:

-(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; 

因此,此刻圖像出現了,但是透明度並不明顯。 背景為純灰色(而不是半透明的灰色)。 圓角組表角上也有黑色角。

知道我哪里出錯了嗎?

將單元格contentViewbackgroundColor設置為clearColor,以刪除黑色邊框。

self.contentView.backgroundColor = [UIColor clearColor];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM