how to change Separator Style for UITableView expandable cell. I am using Custom Tableview Class for that.
Asked
Active
Viewed 3,365 times
-2
-
1Can not understand question properly. please add more detail. you can set separator style using `yourTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine` or `UITableViewCellSeparatorStyleNone` or `UITableViewCellSeparatorStyleSingleLineEtched` – ChintaN -Maddy- Ramani Dec 30 '14 at 11:46
-
3Please search before you post your questions. Your question is a very basic task which was answered very often on this site. For example have a look at this: [Custom Separator](http://stackoverflow.com/questions/1374990/how-to-customize-tableview-separator-in-iphone) – dehlen Dec 30 '14 at 11:46
2 Answers
0
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];

Abhishek Sharma
- 3,283
- 1
- 13
- 22
-
I tried it but it just change my main tableview not to expandable cell. – Dhaval Tannarana Dec 30 '14 at 11:49
-
0
Potentially add a UIView as a separator of your own that has an autoresizing mask set to keep it stuck to the bottom.
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Then in your custom UITableViewCell subclass
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor myColour]; // do cell setup in here
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0.0f, self.contentView.bounds.size.height - 1.0f, self.contentView.bounds.size.width, 1.0f)];
lineView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
lineView.backgroundColor = [UIColor myOtherColour];
[self.contentView addSubview:lineView];
}
return self;
}
If you really want to do it in cellForRowAtIndexPath
you can, but I wouldn't recommend it
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: CellIdentifier];
cell.backgroundColor = [UIColor myColour]; // do cell setup in here
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0.0f, cell.contentView.bounds.size.height - 1.0f, cell.contentView.bounds.size.width, 1.0f)];
lineView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
lineView.backgroundColor = [UIColor myOtherColour];
[cell.contentView addSubview:lineView];
}
// rest of your cell for row code here

Magoo
- 2,552
- 1
- 23
- 43