やることは3つ
- UITableViewの
separatorInset
をゼロにする- これはインターフェースビルダーからでも変更可能
- UITableViewCellの
layoutMargins
をゼロにする - UITableViewCellの
preservesSuperviewLayoutMargins
を無効にする
func viewDidLoad() { super.viewDidLoad() // 1) TableViewのinsetをゼロにする reasonsTable.separatorInset = UIEdgeInsetsZero } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = UITableViewCell() // 2) 自分自身のmarginをゼロにする cell.layoutMargins = UIEdgeInsetsZero // 3) superviewからmarginを引き継がない cell.preservesSuperviewLayoutMargins = false cell.textLabel?.textAlignment = .Center cell.textLabel?.text = self.reasons[indexPath.row].germanText return cell }