uitableview - how to change view's background color in viewForHeaderInSection when view gets tapped in swift -


i using expandable table view. used below logic. if tapped section, unable change view's ground color. have change respective view's ground color when gets tapped. code, red color blinking. dont know why? kindly guide me.

for ex, having 5 sections means, displays 5 views. unable add tag each , every view. dont know how that. kindly guide me.

my coding:

func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? {           var headerview = uiview(frame: cgrectmake(0, 0, sidetableview.frame.size.width, 49))             var layerline = calayer()             layerline.frame = cgrect(x: 0, y: headerview.frame.size.height, width:  headerview.frame.size.width, height: 1)             layerline.backgroundcolor = uicolor(red: 220/255, green: 220/255, blue: 220/255, alpha: 1.0).cgcolor             headerview.backgroundcolor = uicolor(red: 242/255, green: 242/255, blue: 242/255, alpha: 1.0)             headerview.tag = section              headerview.layer.addsublayer(layerline)              var headerstring = uilabel(frame: cgrect(x: 10, y: 10, width: sidetableview.frame.size.width-10, height: 30)) uilabel             headerstring.text = sidetbldata.objectatindex(section) as! nsstring string             headerstring.font = headerstring.font.fontwithsize(15)             headerview .addsubview(headerstring)              headerview.tag = section              let headertapped = uitapgesturerecognizer (target: self, action:"sectionheadertapped:")             headerview .addgesturerecognizer(headertapped)              return headerview      }  func sectionheadertapped(recognizer: uitapgesturerecognizer) {  if(cellclickedbool == true)         {             if(recognizer.view?.tag == 1)             {                 recognizer.view?.backgroundcolor = uicolor.redcolor() //red color blinking              }              cellclickedbool = false         }         else         { recognizer.view?.backgroundcolor = uicolor.whitecolor()              cellclickedbool = true         } } 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -