I have a customized UITableViewCell
. These have the following issues:
- The delete button is too far right, overlapping my background. I'd like to set an inset so that it moves it just a little to the left and then it would look great.
The blue highlighted state spans the entire width of the screen, and I'd like it just to be set inside my curved cell background's bounds.
Is there a way to fix these two issues? Thanks.
Edit: My code is as follows to set the background (just a custom method):
- (UIImage *)cellBackgroundForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger rowCount = [self tableView:[self tableView] numberOfRowsInSection:0];
NSInteger rowIndex = indexPath.row;
UIImage *background = nil;
if (rowIndex == 0) {
background = [UIImage imageNamed:@"cell_top.png"];
} else if (rowIndex == rowCount - 1) {
background = [UIImage imageNamed:@"cell_bottom.png"];
} else {
background = [UIImage imageNamed:@"cell_middle.png"];
}
return background;
}
I then call this method inside a reloadTable
void method that just gets every cell and updates it after there has been a row update (adding or removing a row, because there are 3 different images for the table). I also call this after my fetched results controller gets all my items from Core Data and loads the table up for the first time.
Edit 2: This is the code for the reloadTable
method:
- (void)refreshTable
{
for (NSInteger j = 0; j < [self.tableView numberOfSections]; ++j)
{
for (NSInteger i = 0; i < [self.tableView numberOfRowsInSection:j]; ++i)
{
UIImage *background = [self cellBackgroundForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
cellBackgroundView.image = background;
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];
cell.backgroundView = cellBackgroundView;
}
}
}
The problem is: I have no idea how to set margins or width of a tableView or table view cell. Do I need to subclass something? How is it generally done?