背景が暗い時、tableViewのsectionとsectionの間に白いseparatorが出るので、表示されないようにしたいのですが、何か方法はありますでしょうか?
下記画像のsection2の上のように、白いseparatorが出てしまいます。
こちらを参考にやってみたりしましたが、ダメでした。
http://stackoverflow.com/questions/28597243/removing-last-separator-of-cell-in-table
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
checkベストアンサー
0
とりあえずこちらで確認したコードを貼っておきます。
おそらくseparator
に何かしらの処理をしている様にみえますが(左のマージンが無いため)それが影響しているのかも?
それとカスタムしているCell
を使用しているのでしたら、コードを見ないとこちらでは再現しないため分かりません。
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
typealias sectionType = [(HeaderVew: UIView, height: CGFloat)]
@IBOutlet weak var tableView: UITableView!
// Section Data
let sectionTitleArray = ["section1", "section2"]
var sectionItemArray: [(HeaderVew: UIView, height: CGFloat)] = Array()
// Data Array
var dataArray1 = ["row","row","row","row","row"]
var dataArray2 = ["row","row","row","row","row"]
var dataArrayGroup: [[String]] = []
override func viewDidLoad() {
super.viewDidLoad()
// Create Data
dataArrayGroup = [dataArray1, dataArray2]
// Create Section Header Data
sectionItemArray = self.generateSectionHeader(sectionTitleArray, parentView: self.view)
tableView.tableFooterView = UIView()
tableView.estimatedRowHeight = 20
tableView.rowHeight = UITableViewAutomaticDimension
}
// Generate Section Header Data
func generateSectionHeader(titleArray: [String], parentView: UIView) -> sectionType {
var sectionHeaderArray = sectionType()
for sectionTitle in titleArray {
if sectionTitle.isEmpty {
// No Section Header
sectionHeaderArray.append((HeaderVew: UIView(),height: 0))
} else {
// Create Section Header
let sectionBaseView = UIView(frame: CGRectMake(0, 0, parentView.frame.size.width, 25))
sectionBaseView.backgroundColor = UIColor(red: 0.9843, green: 0.0, blue: 0.5451, alpha: 1.0)
let headerLabel = UILabel(frame: CGRectMake(10, 0, parentView.frame.size.width - 20, 25))
headerLabel.text = sectionTitle
headerLabel.textColor = UIColor.whiteColor()
headerLabel.font = UIFont.boldSystemFontOfSize(17)
sectionBaseView.addSubview(headerLabel)
sectionHeaderArray.append((HeaderVew: sectionBaseView,height: 25))
}
}
return sectionHeaderArray
}
// MARK: - TableView Delegate & DataSource
// Section Header View
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return sectionItemArray[section].HeaderVew
}
// Section Header Height
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return sectionItemArray[section].height
}
// Section Count
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return dataArrayGroup.count
}
// Row Count
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataArrayGroup[section].count
}
// Generate Cell
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel?.text = dataArrayGroup[indexPath.section][indexPath.row]
cell.textLabel?.textColor = UIColor.whiteColor()
cell.backgroundColor = UIColor.blackColor()
return cell
}
}
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
0
読み込んでいるxibファイルのbackgroundをブラックにすると、線が消えた。
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 90.37%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる
質問への追記・修正、ベストアンサー選択の依頼
_Kentarou
2016/09/03 03:57
Sectionは以下のメソッドでViewを返していますか?
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
uemuratt
2016/09/03 04:01 編集
はい、こちらのメソッドを使用してViewを返しております。
_Kentarou
2016/09/03 04:11
自分の手元では(iPhone5s)再現しなかったですが、端末は何で確認してますか?
あとXcodeのバージョンは?
uemuratt
2016/09/14 17:38
ご返信遅くなりまして、申し訳ございません。
読み込んでいるxibファイルが原因でした。
xibファイルのbackgroundカラーをブラックにすると、白い線が出なくなりました。
ご回答ありがとうございました。