Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separatorInset for customization #326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thingineeer
Copy link

@thingineeer thingineeer commented Oct 6, 2023

🪫 [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 this

drop1

Usually, there may be people who want to fill the left side.

What if you add my code? tableView.separatorInset.left = 0


🪫 [After change]

drop2

good


⭐️ But do you see the Separator in the bottom cell?
It's really a little uncomfortable

image

That's okay~

We have customCellConfiguration~

Just create a CGRect with the same color as dropDown in customCellConfiguration and add it to the bottom of dropDown.

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

🍎 Result

drop3

🤔 Review

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant