ios - Issues resizing UITableView header with animation -


i'm tying animate table view's header height 0 its. current code using is:

    var newrect = headerview.frame     newrect.size.height = 0     uiview.animatewithduration(0.6) {         self.headerview.frame = newrect     } 

headerview custom uiview , used so:

 func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? {           return headerview      } 

when run code seems animate headerview's height half size , not 0. ideas might doing wrong here? pointers great.

you have use heightforheaderinsection , uitableview reload system. bellow, there example of how it. it's dummy example (when use presses cell, makes section header (dis)appear.

var displayexpandedheader = true let expandedheight = cgfloat(50) let colapsedheight = cgfloat(0) func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? {     return headerview } func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {      tableview.beginupdates()     displayexpandedheader = !displayexpandedheader     tableview.reloadsections(nsindexset(index: indexpath.section), withrowanimation: (!displayexpandedheader) ? .top : .bottom)     tableview.endupdates() } func tableview(tableview: uitableview, heightforheaderinsection section: int) -> cgfloat {     return (displayexpandedheader) ? expandedheight : colapsedheight } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -