I’m working on an app that uses UITableViews with custom, programmatic UI changes. For instance, I have some programmatic UITableViewCell changes:
...
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:14];
cell.selectedBackgroundView = anImageView;
...
And UITableView settings like this:
self.table.separatorColor = [UIColor darkGrayColor];
How would I make a subclass of a UITableView and UITableViewCell to where whenever I create a new table, it would inherit these properties? I have all of these properties in each table (there’s about 3-4 of them) and would like to reduce unnecessary code clutter.
The UITableViewCell would be the easiest to reuse, as they are (should) always be a separate class (and nib if applicable), however, reusing the Table View itself would require a subclass. This is a little much, considering how easy it is to make UITableViews on a per-class basis, but if you feel you must, you can. Be warned, the UITableView class is extremely picky when it comes to subclasses.