LoginSignup
41
36

More than 5 years have passed since last update.

[Swift] UITableViewの上部にマージン(inset)が自動で設定されてしまうのをstoryboardで解除する。

Last updated at Posted at 2015-08-12

UITableViewやcellをカスタムで作った場合にUITableViewの上部に少しのinsetが表示されることがある。その対処法

コードで対処する方法

直接insetを上書きすることで無理やりinsetを変更することができる。

tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

storyboardで対処する方法

UITableViewを含むViewControllerを選択,下の画像のViewController, Layoutの部分にあるAdjust Scroll View Insetのチェックを外す。
こうすることでinsetがviewdidload時点で変更されることがなくなる。

スクリーンショット 2015-08-12 12.59.12.png

41
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
36