SplitRow
SplitRow copied to clipboard
Set cell.backgroundColor in .cellSetup not working
Hi there,
I might be doing it wrong, but when I set up one of my splitcells, the .cellSetup method does not appear to be applied to my splitCell.
e.g. the cell background colour for my right row will stay white. This is how I normally set up cells that are not in a splitCell configuration.
<<< SplitRow<SwitchRow, TextRow>(){
$0.rowLeftPercentage = 0.2
$0.rowLeft = SwitchRow() {
$0.value = false
$0.tag = "isEventSet"
}
$0.rowRight = TextRow(){ row in
row.title = "TEST"
row.tag = "TEST"
}.cellSetup { cell, row in
cell.backgroundColor = .red
}
}
hi @primeviltom!
Are you on iOS 13 using SplitRow v2.1.1? If so, this issue is probably related to the dark mode fix we introduced here: https://github.com/EurekaCommunity/SplitRow/issues/41
Can you confirm your code works in SplitRow <= v2.1.0 - or do you experience the same (wrong) behaviour there?
G'day @marbetschar - thanks for the quick response..
I've just tried the same code with v 2.1.0 and v 2.0.0, and both had the same (incorrect) behaviour =[
Will look into it. For now, you're maybe able to use .cellUpdate instead of .cellSetup to set the .backgroundColor - From what I know this should work as expected.
PS: Which iOS version do you use?
cellUpdate is a good enough work around - works well enough for my requirements!
This is running on iOS 13.0 on the simulator, and iOS 13.1.3 on a physical device.
Hello,
Thank you for your work for SplitRow :)
When I was using 1.1.1 version, I wanted to have the right field as a Button, with green background color and test as white. That was working with the following lines at the rowRight level:
row.cell.tintColor = .white
row.cell.backgroundColor = UIColor.MPGreen()
However, now that I tried to upgrade to 2.2.1 this has been broken and I get a white background at the right sub sell. I tried the workaround of using the cellUpdate, and is working! However, on the left of green button, there is a small vertical line (the separator) that appears as white and cuts a portion of the button rectangle...
$0.rowRight = ButtonRow(){ (row: ButtonRow) -> Void in
row.title = localized("btn_add")
row.cell.tintColor = .white
// row.cell.backgroundColor = UIColor.MPGreen() // code from 1.1.1
}
.onCellSelection { [weak self] (cell, row) in
print("VitalSignsViewController: Button pressed")
if let parent = self {
parent.actionAdd()
}
}
// new workaround
.cellUpdate { cell, row in
row.cell.backgroundColor = UIColor.MPGreen()
}
}.
As a workaround, I changed the SplitRowCellTableView.swift (I had the same issue in 1.1.1 version):
// separatorView.backgroundColor = .groupTableViewBackground
separatorView.backgroundColor = .clear
This change in your code worked, but is it possible to help with this in order to avoid changing your code?
Best regards,
Kostas
@kmav what happens if you set tableViewRight.leftSeparatorStyle in SplitRowCell to .none? Does this fix your issue?
https://github.com/EurekaCommunity/SplitRow/blob/b60b6ab85786cab438e8c3e940fc38cce38fd08c/SplitRow/SplitRowCell.swift#L32-L33
If this helps, we possibly can make this public configurable as splitRow.separatorStyle...
Thank you @marbetschar for your review.
I reverted my change in SplitRowCellTableView back to:
separatorView.backgroundColor = .groupTableViewBackground
And set tableViewRight.leftSeparatorStyle in SplitRowCell to .none.
I can confirm that I don't experience the issue.

May I ask what is the purpose and use of this separator?
Best regards, Kostas
@kmav lets further discuss this in https://github.com/EurekaCommunity/SplitRow/issues/45