Open thingineeer opened 10 months ago
When implementing a custom drop-down menu, a separator is often needed.
dropDown.separatorColor's default color is .clear right?
.clear
But if you use dropDown.separatorColor = .black here, it looks like this
dropDown.separatorColor = .black
Usually, there may be people who want to fill the left side.
left side
What if you add my code? tableView.separatorInset.left = 0
tableView.separatorInset.left = 0
good
⭐️ But do you see the Separator in the bottom cell? It's really a little uncomfortable
Separator
That's okay~
We have customCellConfiguration~
customCellConfiguration
Just create a CGRect with the same color as dropDown in customCellConfiguration and add it to the bottom of dropDown.
CGRect
Like this
dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in let lastDivideLineRemove = UIView(frame: CGRect(origin: CGPoint(x: 0, y: 119), size: CGSize(width: 170, height: 10))) lastDivideLineRemove.backgroundColor = .white // ⭐️ Same as the background color of dropDown cell.addSubview(lastDivideLineRemove) }
dropDown.customCellConfiguration = { (index, item, cell) in cell.separatorInset = .zero cell.layoutMargins = .zero }
You can add it like this, but I think it's better to just add tableView.separatorInset.left = 0 😄
🪫 [Before change]
When implementing a custom drop-down menu, a separator is often needed.
dropDown.separatorColor's default color is
.clear
right?But if you use
dropDown.separatorColor = .black
here, it looks like thisUsually, there may be people who want to fill the
left side
.What if you add my code?
tableView.separatorInset.left = 0
🪫 [After change]
good
⭐️ But do you see the
Separator
in the bottom cell? It's really a little uncomfortableThat's okay~
We have
customCellConfiguration
~Just create a
CGRect
with the same color as dropDown incustomCellConfiguration
and add it to the bottom of dropDown.Like this
🍎 Result
🤔 Review
You can add it like this, but I think it's better to just add
tableView.separatorInset.left = 0
😄