How can I increase the space between the title and subtitle in UITableViewCell?
The best way would be to just subclass UITableViewCell. That way, you can have total and complete control over the position of the labels. If this is not an option, you could modify each label's frame manually.
You can add two labels in your cell content view instead of setting cell label. Adjust the y origin as per need. Adding heightForRowAtIndexPath will increase your cell height.
subclass UITableViewCell to create a custom cell. Here is a great way to do this. It's simple and will also allow you future potential in making your cells look the way you want them to. The other nice thing about it is that each cell is generic, so you only have to create one customized class.
If your row height is greater then the title and subtitle will be vertically middle align.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
UITableViewCell
) for your custom cell.
update your table view class.
use your custom cell's identifier in cellForRowAtIndexPath
.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = YOUR CUSTOM CELL's IDENTIFIER;
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
//configure your cell.
cell.YOURLABEL1.text=@"YOUR TEXT FOR LABEL 1";
cell.YOURLABEL2.text=@"YOUR TEXT FOR LABEL 2"
return cell;
}
thats It.