ios - Animation inside last cell of tableview -
i have table view. inside cell have method animates view inside cell.
func animatecell() { uiview.animate(withduration: 0.4, animations: { [weak self] in self?.quantitybackround.transform = cgaffinetransform(scalex: 25, y: 25) }) { [weak self] _ in uiview.animate(withduration: 0.1) { self?.quantitybackround.transform = cgaffinetransform.identity } } } also have prepareforreuse()
override func prepareforreuse() { quantitybackround.transform = cgaffinetransform.identity } the animation must work last cell when array of datasource changes , in property observer (fires when being added array)
guard let cell = checktableview.cellforrow(at: indexpath(row: viewmodel.checkmanager.check.count - 1, section: 0)) as? checkitemtableviewcell else { return } cell.animatecell() all of works fine.
one problem, encounter when tableview reloaded, background views in cells expand 0 size initial. last cell animates ok.
i think miss in prepareforreuse , because of see glitch of inreasing 0 initial size.
how fix ?
you need implement method of uitableviewdelegate
func tableview(_ tableview: uitableview, willdisplay cell: uitableviewcell, forrowat indexpath: indexpath) { //here check if cell last one, if (indexpath.row == yourdatasourcearray.count - 1) { if let customcell = cell as? checkitemtableviewcell{ customcell.animatecell() } } } hope helps
Comments
Post a Comment