mercredi 24 juin 2015

Swift: Place UITableViewCell beneath siblings

I'm trying to build a custom UITableView that acts in a similar way to the reminders app.

Instead of the top-most visible cell scrolling off the display, I want it to be covered by the next cell so the cells appear to stack on top of one another as you scroll.

Currently I am using

override func scrollViewDidScroll(scrollView: UIScrollView) {

  let topIndexPath: NSIndexPath = tableView.indexPathsForVisibleRows()?.first as! NSIndexPath

  let topCell = tableView.cellForRowAtIndexPath(topIndexPath)

  let frame = topCell!.frame

  topCell!.frame = CGRectMake(frame.origin.x, scrollView.contentOffset.y, frame.size.width, frame.size.height)

But the top cell is always above the second cell - causing the second cell to scroll under it.

Also if I scroll quickly this seems to misplace all of my cells.

See more ..

Aucun commentaire:

Enregistrer un commentaire