iosswifttableviewtitlenavigationcontroller

How to create Subtitle or Smaller Title under the Large title in Swift


I want to create a a title page that look similarly like on the Health App. It has Large title 'Summary' and a smaller title 'Favorites'

Health app

I'm able to create the Large title by Prefers Large Title. But how do I create the smaller title like 'Favorites' in Health app?

Here's a look at my app :

enter image description here

UPDATE :

With the help of my friends here, I was able to create the header view closer to my expectation, but it needs a bit modification. Here's what it looks like now :New updated


Solution

  • Add a custom viewForHeader for your UITableView.

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let label = UILabel()
        label.text = "Small title"
        label.font = .boldSystemFont(ofSize: 32) // give your required value here
        return label
    }