joda joda - 1 year ago 121
Swift Question

add uiview above uitableview

I use this ENSwiftSideMenu
it's just a tableView written programmatically,
I want to add a custom view above

in this side menu,
this view contain an
and text label, like this

enter image description here

How I can do that? and this view's outlet where should I write it? because I just have a tableview class

Answer Source

Inside your viewController where you are creating tableView, Just set your custom view as tableHeaderView in your viewDidLoad.

let headerView = CustomHeaderView()
self.tableView.tableHeaderView = headerView

Edit: Follow this steps to set custom tableHeaderView.

1 ) Create UIView with xib and add Image and Label or other thing that you want inside the UIView.

2 ) Initialize its object in your viewController where you have added tableView.

 let view = CustomHederView()
 view.imageView.image = image //Set image that you want
 view.lblName.text = Name // Set Name

3 ) Set this custom view as tableHeaderView

 self.tableView.tableHeaderView = view