开发者

iPhone:How to set background image for tablerow cell?

开发者 https://www.devze.com 2022-12-31 18:35 出处:网络
I want to put some background image for TableView row cell. I am using the following code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

I want to put some background image for TableView row cell. I am using the following code:

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

.....................

...................

UIImage * backgroundImage = [UIImage imageNamed:@"cell.png"]; UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];

cell.opaque = NO;

cell.contentView.opaque = NO;

cell.backgroundColor = [UIColor clearColor];

cell.backgroundColor = backgroundColor;

//cell.contentView.backgroundColor = [UIColor clearColor];

//cell.contentView.backgroundColor = backgroundColor;

}

But it is not giving the background image properly. Could someone guide me what is the proper ways of setting background image for a tableview row? Note: I'm also setting background image for my TableView as well using the below c开发者_JAVA技巧ode:

UIImage * backgroundImage = [UIImage imageNamed:@"Tablebackground.png"];
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];
self.myTableView.backgroundColor = [UIColor clearColor];
self.myTableView.alpha = 0.9;
self.myTableView.backgroundColor = backgroundColor;

I don't observe any problem for tableview background. Only thing here is, tableview background image is not being static, when scrolling happening, image is also scrolling.

But i want to know first how to set background image for Tableview row cell?

Thank you.


This is by far the best tutorial I've ever read on UITableView customization: http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

0

精彩评论

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