ios - UICollectionView: animating an in-cell animation -


i working on card-style ui. within uicollectionview single cell takes of collectionview frame. collectionview has 1 item in it. when user wants go next card (on-screen button) use collectionview.insertitems add next 'card' , collectionview.deleteitems remove previous one. override layout attributes create effect old card scaling , new card animating in, on top of it:

override open func finallayoutattributesfordisappearingitem(at itemindexpath: indexpath) -> uicollectionviewlayoutattributes? {     let layoutattibutes = layoutattributesforitem(at: itemindexpath)?.copy() as! uicollectionviewlayoutattributes      layoutattibutes.center = cgpoint(x: (layoutattibutes.center.x), y: (layoutattibutes.center.y) )     layoutattibutes.transform = cgaffinetransform(scalex: 0.95, y: 0.95)     layoutattibutes.zindex = 0      return layoutattibutes }  override open func initiallayoutattributesforappearingitem(at itemindexpath: indexpath) -> uicollectionviewlayoutattributes? {     let layoutattibutes = layoutattributesforitem(at: itemindexpath)?.copy() as! uicollectionviewlayoutattributes      layoutattibutes.center = cgpoint(x: (layoutattibutes.center.x), y: (layoutattibutes.center.y) )     layoutattibutes.transform = cgaffinetransform(translationx: 0, y: 1000)     layoutattibutes.zindex = 5      return layoutattibutes } 

in addition scaling stacking/leaving card, want darken it. have .darkencard() function within cardcollectionviewcell class. trigger on-screen button:

@ibaction func nextcard(_ sender: any) {     currentstepnumber += 1      if currentstepnumber == 10 {         currentstepnumber = 1 }      let indexpath0 = indexpath(item: 0, section: 0)     let indexpath1 = indexpath(item: 1, section: 0)     let stackingcard = collectionview.cellforitem(at: indexpath0) as! cardcollectionviewcell      stackingcard.darkencard()         collectionview.reloaditems(at: [indexpath0])      steplist.addstepdata(stepnumber: currentstepnumber)     collectionview.insertitems(at: [indexpath0])      if steplist.itemcount() != 0 {         steplist.deletestep(itemnumber: 0)         collectionview.deleteitems(at: [indexpath1])     } }  

issues/questions

(1) darkencard() happens instantly. how animate happen while cell/card being scaled down?

(2) when added .reloaditems(at:) following message each time button pressed:

2017-04-14 14:52:05.699 cardexp[98924:3166090] snapshotting view has not been rendered results in empty snapshot. ensure view has been rendered @ least once before snapshotting or snapshot after screen updates.

i can't quite figure i've done (or not done) , out how fix it.

(3) in initiallayoutattributesforappearingitem , finallayoutattributesfordisappearingitem how control animation settings? example, how add spring or or delay new card animating on. did moved initial position further away force spend of it's animation time offscreen. works, doesn't seem correct way do. should have done?


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -