Changing Font Size For UITableView Section Headers
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Changing section header font size in UITableView looks simple, but the default header API gives very limited typography control. In production apps, teams usually need consistent branding, Dynamic Type support, and readable headers across devices. The most reliable approach is to use a custom header view and drive style through code instead of relying on default title rendering.
Why Default Section Headers Are Limited
When you return text from tableView(_:titleForHeaderInSection:), UIKit builds the header label internally. That internal label is not designed for deep styling, so changing font family, size, and spacing is inconsistent and fragile. You can sometimes alter appearance globally with UITableViewHeaderFooterView.appearance(), but that affects every table and can cause side effects.
For predictable behavior, move to tableView(_:viewForHeaderInSection:) and return your own UITableViewHeaderFooterView. This gives full control over typography, colors, layout margins, and accessibility behavior.
Build a Reusable Header View
A reusable subclass is the cleanest foundation. It centralizes font logic and avoids copy-paste header code in every view controller.
This class exposes a configure method so your table controller can vary font size per section when needed. If your style is fixed, you can remove pointSize and keep a single design token.
Connect the Header View in UITableView
Register the header view and return it from the delegate method. This pattern is safe with reuse and keeps scrolling smooth.
With this setup you can easily tune typography for hierarchy, such as a larger first section and standard size for the rest.
Support Dynamic Type and Accessibility
Hardcoding a single size can hurt accessibility. If your design allows scaling, use UIFontMetrics so custom fonts grow with system text settings.
This preserves design intent while remaining accessible for users with larger text preferences.
Common Pitfalls
Teams often keep titleForHeaderInSection and viewForHeaderInSection at the same time, then wonder why styling seems random. Once you use a custom view, remove default header title logic. Another frequent issue is forgetting to register the header class, which causes dequeue failures and missing headers. Fixed heights can also clip larger fonts, especially under accessibility sizes, so test with larger content categories and increase header height if needed. Finally, global appearance customization can unintentionally affect unrelated tables, so scope styles to reusable header views whenever possible.
Summary
- Default table section titles are easy, but they do not provide robust font control.
- A custom
UITableViewHeaderFooterViewis the most reliable way to control size, weight, and spacing. - Register header views once and reuse them for smooth scrolling performance.
- Use
UIFontMetricsand Dynamic Type support to avoid accessibility regressions. - Remove conflicting header APIs and test with larger text settings before shipping.

