ios - How to implement UIVibrancyEffect for table view header? -



ios - How to implement UIVibrancyEffect for table view header? -

i table view section headers text rendered in vibrant style, underlying ui shines through text. have tried following, nil appears header if returned nil.

override func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? { //add vibrancy text effect allow blureffect = uiblureffect(style: .light) allow vibrancyeffect = uivibrancyeffect(forblureffect: blureffect) allow vibrancyeffectview = uivisualeffectview(effect: vibrancyeffect) //label vibrant text allow vibrantlabel = uilabel() vibrantlabel.text = "testing" vibrantlabel.font = uifont.systemfontofsize(11.0) vibrantlabel.textcolor = uicolor(white: 0.64, alpha: 1) vibrancyeffectview.contentview.addsubview(vibrantlabel) homecoming vibrancyeffectview }

solved it. problems code provided in question are: had set frames view , label (duh), , needed specify blur effect style .dark not .light ensure text lite colored not dark. has same question, here's code. you'll want tweak position/size/etc of text i'm sure. note had applied blur effect table view's background.

//create vibrancy text effect allow blureffect = uiblureffect(style: .dark) allow vibrancyeffect = uivibrancyeffect(forblureffect: blureffect) allow vibrancyeffectview = uivisualeffectview(effect: vibrancyeffect) vibrancyeffectview.frame = cgrectmake(0, 0, tableview.frame.size.width, 40) vibrancyeffectview.autoresizingmask = .flexiblewidth //create header label allow vibrantlabel = uilabel() vibrantlabel.frame = vibrancyeffectview.frame vibrantlabel.autoresizingmask = .flexiblewidth vibrantlabel.text = "testing" vibrantlabel.font = uifont.systemfontofsize(16) vibrantlabel.textcolor = uicolor(white: 0.64, alpha: 1) vibrancyeffectview.contentview.addsubview(vibrantlabel) homecoming vibrancyeffectview

ios uitableview swift uiblureffect uivibrancyeffect

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -