PDA

View Full Version : iPhone change uitableview grouped style background texture's color




isparkdev
Jun 1, 2009, 03:25 AM
Hi,
Is it possible to change background color of uitableview (style grouped) while still preserving the texture of vertical lines.
If i change background color the texture is lost & i get a plain background.



jnic
Jun 1, 2009, 05:15 AM
[UIColor groupTableViewBackgroundColor (http://developer.apple.com/iphone/library/documentation/uikit/reference/UIColor_Class/Reference/Reference.html#//apple_ref/occ/clm/UIColor/groupTableViewBackgroundColor)]

johnnyjibbs
Jun 1, 2009, 06:09 AM
The grouped table view background colour is actually a pattern. If you want to create your own custom version of the default pattern you could capture a small 'tile' (for this pattern the smallest possible tile would be two columns wide, 1 pixel down) and then open it up in a paint program and change the colours to whatever you want.

Then create your own colour using the new pattern:


tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mypattern.png"]];


(Note that UIImage's imageNamed: method is pure evil but on an image size of about 4 x 1 pixels it will not cause you any memory issues).