简体   繁体   中英

UIView on top of cell in UITableView

I have a cell on which I want to put a view like this:

 ------------------------------------------------

                     Cell 1 
                   ----------
                  |          |
 -----------------    View    -------------------
                  |          |
                   ----------

                     Cell 2
 ------------------------------------------------

But when I add it on cell 1, it ends up being like this because cell 2 hides half of it:

 ------------------------------------------------

                     Cell 1 
                   ----------
                  |   View   |
 ------------------------------------------------    



                     Cell 2
 ------------------------------------------------

First, check the clipsToBounds property:

cell.clipsToBounds = NO;

Second, you need to have have the other cell to have a transparent background that is being drawn in the last possible moment:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell 
        forRowAtIndexPath:(NSIndexPath *)indexPath {
    cell.backgroundColor = [UIColor clearColor];
}

If this does not work, try the cell's contentView as well.

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