Help us understand the problem. What is going on with this article?

【Swift 4対応】UITableView (Grouped style) でのセパレータコントロール

More than 1 year has passed since last update.

注意

UITableView に含まれるセパレータの役割を担う View は、 UITableViewCellSeparatorView という private な class です。この記事の方法は非推奨な方法となりますので、テクニックの一つとして御覧ください。

セクショングループの上下セパレータを非表示にする

Untitled.001.png

class SampleCell: UITableViewCell {
    override func layoutSubviews() {
        super.layoutSubviews()
        let targetName = "_UITableViewCellSeparatorView"
        for view in subviews {
            // グループの上下セパレータを非表示
            view.isHidden = view.frame.origin.x == 0 && NSStringFromClass(view.classForCoder) == targetName
        }
    }
}

本当は

上記のようなデザインを実現したい場合は、自分でセパレータを作ってコントロールするのが良さそうです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした