开发者

How to set the background image for last cell and find the table view height in iPhone?

开发者 https://www.devze.com 2023-02-09 13:57 出处:网络
I have created table view and displayed the datas. I have used to different background image for the table view cell. I have displayed the datas are dynamically in the table view. I want to displayed

I have created table view and displayed the datas. I have used to different background image for the table view cell. I have displayed the datas are dynamically in the table view. I want to displayed the background image for the last table view cell which depends on the table view frame height, please see my image,

How to set the background image for last cell and find the table view height in iPhone?

.

Here my sample code,

if 开发者_运维技巧([indexPath row]%2) {

        cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cellbg1.png"]];

    }else{

        cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cellbg2.png"]];
    }

    cell.backgroundView.contentMode = UIViewContentModeScaleToFill;

    cell.backgroundView.alpha = 0.5;

So how can i fill the background image for the last cell which depends on the table view frame. And is any possible to find the table view height of displaying the contents of the data in table only. Please guide me.

Thanks.


Are you looking for table.bounds.size.height? That would be the height of the viewable area of the table.

Or are you looking for the total height of the content in the table? Then you can use table.contentSize.height.


Rather than setting the background of the last cell, you may want to use

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

method and set a footer view for the table.

0

精彩评论

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