开发者

UITableView background image problem

开发者 https://www.devze.com 2023-04-05 11:01 出处:网络
I am using UITableView.I开发者_JAVA百科 set the tableview background image like this. self.tableView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@\"bg.png\"]];

I am using UITableView.I开发者_JAVA百科 set the tableview background image like this.

self.tableView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];

UITableView background image problem

I am using table style as grouped. But in display I am getting black shadow on left and right side of grouped cell.

How to remove this black shadow?

Thanks in Advance.


Try this..

self.tableView.backgroundColor=[UIColor clearColor];
UIImage *backgroundImage = [UIImage imageNamed:@"sample2.png"];
UIImageView *backgroundImageView = [[UIImageView alloc]initWithImage:backgroundImage]; 
self.tableView.backgroundView=backgroundImageView;
[backgroundImageView release];


First, set the background image for the table's parent view to the image that you want:

[parentView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];

Then, set the background image for the UITableView to clearColor:

self.tableView.backgroundColor = [UIColor clearColor];

That should solve the problem.


Set the opaque property to NO:

[self.tableView setOpaque: NO];


Set the tableview's backgroundColor to clearColor and set the tableview's backgroundView to nil and it will show the color of the view on which it was added on to. And if your tableview is a standalone grouped style table view controller, then set its opaque property to NO.


You can use these lines instead of the above line to get rid of black color :

UIImage *backgroundImage = [UIImage imageNamed:@"b.jpg"];   
UIImageView *backgroundView = [[UIImageView alloc]initWithImage:backgroundImage];
[self.view addSubview:backgroundView];  
[self.view sendSubviewToBack:backgroundView];   
0

精彩评论

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