You need to set the view not to a string.
You can set a label in the field of view and set this view in the table header.
var view1: UIView = UIView.init(frame: CGRectMake(0, 0, 320, 600)); var label: UILabel = UILabel.init(frame: CGRectMake(0, 0, 320, 600)) view1.addSubview(label); self.tableView.tableHeaderView = view1;
source share