Created
May 8, 2019 07:58
-
-
Save macneko-ayu/83170f6ae91453b95128a7175a228ea0 to your computer and use it in GitHub Desktop.
UITableViewCellのsubviewsを走査してセパレーターを非表示にするやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 参考: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