Reputation: 1608
Im trying to add this particular header to my iphone app which lives in UIViewController
The current implementation
What I want to achieve
The only solution that I could think of to add this particular header is using image view in object library
How do i do add it?
Upvotes: 0
Views: 299
Reputation: 15335
Use the viewForHeaderInSection
delegate method to customise table section headerView
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
}
and don't forget to implement the method.
func tableView(_ tableView: UITableView,
heightForHeaderInSection section: Int) -> CGFloat
Upvotes: 1
Reputation:
Try this code it works
set the section header height in the viewDidLoad
self.tableView.sectionHeaderHeight = your desired height(in int)
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 18))
let imageview = UIImageView(frame: CGRect(x: 20, y: 20, width: 50, height: 50))
self.view.addSubview(imageview)
return view
}
set images in your imageview according to your requirements
Upvotes: 0