ios - uitableview header background not shown until scroll -
i used following code set header view of uitableview section. problem is, background color (mainlightcolor_2) doesn't show until scroll tableview. how can make background color shown on load?
- (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { uiview *headerview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 24)]; headerview.backgroundcolor = [utility mainlightcolor_2]; //mainlightcolor blue color uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(5, 2, 200, 20)]; label.backgroundcolor = [uicolor clearcolor]; label.textcolor = [utility maindarkcolor]; label.text = @"past activities"; [headerview addsubview:label]; return headerview; }
before scroll:
after scroll:
you should implement - (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section
method.
- (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section{ return 24; }
Comments
Post a Comment