SplitRow icon indicating copy to clipboard operation
SplitRow copied to clipboard

Set cell.backgroundColor in .cellSetup not working

Open primeviltom opened this issue 6 years ago • 8 comments

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
            }
            
        }

primeviltom avatar Nov 14 '19 06:11 primeviltom

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?

marbetschar avatar Nov 14 '19 06:11 marbetschar

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 =[

primeviltom avatar Nov 14 '19 08:11 primeviltom

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?

marbetschar avatar Nov 14 '19 08:11 marbetschar

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.

primeviltom avatar Nov 14 '19 22:11 primeviltom

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 avatar Apr 19 '20 21:04 kmav

@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...

marbetschar avatar Apr 20 '20 05:04 marbetschar

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.

Screenshot 2020-04-20 at 13 12 26

May I ask what is the purpose and use of this separator?

Best regards, Kostas

kmav avatar Apr 20 '20 10:04 kmav

@kmav lets further discuss this in https://github.com/EurekaCommunity/SplitRow/issues/45

marbetschar avatar Apr 20 '20 16:04 marbetschar