ExtraViewの使い方
@ktsukago
自己紹介
塚越 啓介
iOS/Agile/ピエロnew
ゴメン
ナサイ
swift
じゃない
ExtraView
“Add and edit views
outside of the main view
controller by adding them
to the scene dock.”
利用例
SectionHeaderに
使ってみました
Section Headerの
カスタマイズ
面倒じゃないですか?
コードで書いてたり
func tableView(tableView: UITableView, viewForHeaderInSection
section: Int) -> UIView?
{
let label = UILabel(frame: CGRect(x:0, y:0, width:
tableView.bounds.width, height: 50))
label.textAlignment = NSTextAlignment.Center
label.font = UIFont.italicSystemFontOfSize(21)
label.backgroundColor = UIColor.redColor()
label.textColor = UIColor.whiteColor()
label.text = "タイトル
return label
}
xib使ってたり
xib使ってたり
// headerの登録
let nib = UINib(nibName: “CustomHeaderView”,bundle:nil)
self.tableView.registerNib(nib: nib,
forHeaderFooterViewReuseIdentifier: "CustomHeaderView")
// headerのdequeue
tableView.dequeueReusableHeaderFooterViewWithIdentifier("CustomHeade
rView")
正直みづらい
なんでTableViewController
にSectionがないんだ!!
せっかくのStoryboard
cellもheaderも同じ画面で
めっちゃべんり!
注意 : Copyで渡さないと・・・
// MARK: - UITableViewDelegate
extension TimelineViewController:UITableViewDelegate {
func tableView(tableView: UITableView, viewForFooterInSection
section: Int) -> UIView? {
let copiedFooter =
NSKeyedUnarchiver.unarchiveObjectWithData(NSKeyedArchiver.archivedDat
aWithRootObject(self.sectionFooterView)) as!
TimelineSectionFooterView
return copiedFooter
}
func tableView(tableView: UITableView, heightForFooterInSection
section: Int) -> CGFloat {
return self.sectionFooterView.frame.size.height
}
}
まとめ
めっちゃべんり!
Extra view @ kyobashi.swift

Extra view @ kyobashi.swift