現在、実際に試せないのですが、ヘッダやフッタ、もしくはセクションを使って実現できないでしょうか?
#やってみる
#####セクションのヘッダ/フッタを使う
swift
1//ヘッダ(上の線)
2func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
3 let view = UIView()
4 view.backgroundColor = UIColor.greenColor() //お好きな色に
5 return view
6}
7
8//フッタ(下の線)
9func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
10 let view = UIView()
11 view.backgroundColor = UIColor.orangeColor() //お好きな色に
12 return view
13}
14
15//ヘッダの高さ(上の線の幅)
16func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
17{
18 return 1 //お好きな高さに
19}
20
21//フッタの高さ(下の線の幅)
22func tableView(tableView: UITableV![イメージ説明](344a0bbcf888030f87c495bcc129513b.png)説明](7de0ad87abd0c7a94bf82d726fab393f.png)eightForFooterInSection section: I![イメージ説明](26b361b44483da144758a3fd28f2ec62.png) CGFloat
23{
24 return 1 //お好きな高さに
25}
#####テーブルのヘッダ/フッタを使う
こっちの方がシンプルで良さげ。
swift
1class ViewController: UIViewController {
2
3 @IBOutlet weak var table: UITableView!
4
5 override func viewDidLoad() {
6 super.viewDidLoad()
7
8 let frame = CGRectMake(0, 0, CGRectGetWidth(table.frame), 1/*お好きな高さに*/)
9 table.tableHeaderView = UIView(frame: frame)
10 table.tableFooterView = UIView(frame: frame)
11 table.tableHeaderView!.backgroundColor = UIColor.greenColor() //お好きな色に
12 table.tableFooterView!.backgroundColor = UIColor.orangeColor() //
13 }
14 :
15}
#できあがり
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/27 23:46 編集
2016/04/28 00:38
2016/04/28 12:57