Skip to content

Instantly share code, notes, and snippets.

@macneko-ayu
Created May 8, 2019 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macneko-ayu/83170f6ae91453b95128a7175a228ea0 to your computer and use it in GitHub Desktop.
Save macneko-ayu/83170f6ae91453b95128a7175a228ea0 to your computer and use it in GitHub Desktop.
UITableViewCellのsubviewsを走査してセパレーターを非表示にするやつ
// 参考:https://stackoverflow.com/questions/29006311/grouped-uitableview-remove-outer-separator-line
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.subviews.forEach { subview in
if subview != cell.contentView, subview.frame.width == cell.frame.width, subview.frame.height == 0.5 {
// 特定のセクション、かつ特定のクラスだけ処理を変える場合
if indexPath.section == 99,
let cell = cell as? SampleTableViewCell {
// TODO: なにかする
} else {
subview.isHidden = true
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment