简体   繁体   中英

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

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,

图片 .

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM