2012-03-27 54 views
0

我想我的表的背景更改爲圖像,這工作正常在4.3:backgroundView /的backgroundColor上的UITableView在iOS5.1

table.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"backgroundTile.png"]]; 
在5.1沒有,都是我

然而得到是一個白色背景。我已經嘗試了這些替代方法,但都沒有成功。

table.backgroundColor = [UIColor clearColor]; 
UIView *view = [[[UIView alloc] init] autorelease]; 
view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundTile.png"]]; 
table.backgroundView = view; 

或本

table.backgroundColor = [UIColor clearColor]; 
UIImageView *bgview = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"backgroundTile.png"]]; 
table.backgroundView = bgview; 
[bgview release]; 

或本

table.backgroundColor = [UIColor clearColor]; 
UIView *bgview = [[[UIView alloc] initWithFrame: CGRectMake(table.frame.origin.x, table.frame.origin.y, table.frame.size.width, table.frame.size.height)] autorelease]; 
bgview.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"backgroundTile.png"]]; 
table.backgroundView = bgview; 

奇怪的是,如果不是使用colorWithPatternImage,我用說綠彩,那麼工作。儘管我試圖獲得一張圖片。

感謝您的幫助。

回答

0

所以問題在於png缺少透明度。