2012-03-27 55 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缺少透明度。