diff --git a/ContactsApp/Base.lproj/Main.storyboard b/ContactsApp/Base.lproj/Main.storyboard
index f1051fd..07a73d2 100644
--- a/ContactsApp/Base.lproj/Main.storyboard
+++ b/ContactsApp/Base.lproj/Main.storyboard
@@ -19,16 +19,8 @@
-
-
-
-
-
-
-
-
-
+
@@ -59,7 +51,7 @@
-
+
diff --git a/ContactsApp/ContactSection.xib b/ContactsApp/ContactSection.xib
index 0c34df4..b5750f7 100644
--- a/ContactsApp/ContactSection.xib
+++ b/ContactsApp/ContactSection.xib
@@ -27,7 +27,7 @@
-
+
diff --git a/ContactsApp/ContactSectionView.swift b/ContactsApp/ContactSectionView.swift
index b2c0db1..1f7e308 100644
--- a/ContactsApp/ContactSectionView.swift
+++ b/ContactsApp/ContactSectionView.swift
@@ -8,14 +8,8 @@
import UIKit
-class ContactSectionView: UIView {
+class ContactSectionView: UITableViewHeaderFooterView {
@IBOutlet weak var labelLetter: UILabel!
@IBOutlet weak var labelExpandable: UIButton!
-
- override func draw(_ rect: CGRect) {
- super .draw(rect)
- //title.text = "Jahata"
- }
-
}
diff --git a/ContactsApp/ContactsViewController.swift b/ContactsApp/ContactsViewController.swift
index dacdd22..7f34c2a 100644
--- a/ContactsApp/ContactsViewController.swift
+++ b/ContactsApp/ContactsViewController.swift
@@ -18,6 +18,7 @@ class ContactsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
+ contactsTable.register(UINib(nibName: "ContactSection", bundle: nil), forHeaderFooterViewReuseIdentifier: "headerId")
importContacts()
contactsTable.tableFooterView = UIView(frame: .zero)
}
@@ -110,14 +111,15 @@ extension ContactsViewController: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- let button = UIButton(type: .system)
- button.setTitle("Λ", for: .normal)
- button.setTitleColor(.black, for: .normal)
- button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
- button.backgroundColor = .systemGray4
- button.addTarget(self, action: #selector(interactSection), for: .touchUpInside)
- button.tag = section
- return button//ʌΛ
+ let header = contactsTable.dequeueReusableHeaderFooterView(withIdentifier: "headerId") as! ContactSectionView
+ header.contentView.backgroundColor = .systemGray4
+ header.labelExpandable.setTitle("Λ", for: .normal)
+ header.labelExpandable.setTitleColor(.black, for: .normal)
+ header.labelExpandable.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
+ header.labelExpandable.addTarget(self, action: #selector(interactSection), for: .touchUpInside)
+ header.labelExpandable.tag = section
+ header.labelLetter.text = contactStructArray[section].letter
+ return header//ʌΛ
}
@objc func interactSection(button : UIButton) {