How can we add image in UITableView section header using swift?

前端 未结 6 1504
盖世英雄少女心
盖世英雄少女心 2021-02-04 10:54

In my willDisplayHeaderView I have changed color of section header But I want to add an image before section title. Any help? My code for willDisplayHeaderView is



        
6条回答
  •  悲哀的现实
    2021-02-04 11:14

    Simply Add the following code in your viewDidLoad() method.

        var frame = CGRectMake(0, 0, self.view.frame.size.width, 200)
        var headerImageView = UIImageView(frame: frame)
        var image: UIImage = UIImage(named: "yourImage")!
        headerImageView.image = image
        youTableView.tableHeaderView = headerImageView
    

提交回复
热议问题