Avatar ·

How to change UILabel font size in Swift? (programmatically and in Interface Builder)

Hello everyone! I just started learning Swift and am writing my first app — a simple to-do list. I have a task detail screen where the task name is displayed in a UILabel. I want the task title to be larger than normal text (e.g., 24pt) and the description to be standard (17pt).\n\nThe problem is that I can't figure out how to properly change the font size programmatically. In Interface Builder, I see the Font field in the Attributes Inspector, but when I change it there, the size only applies to that specific instance. I need the font size to be able to change dynamically based on user settings (e.g., via a slider).\n\nHere's how I'm trying to do it now:\n\n```swift\nimport UIKit\n\nclass DetailViewController: UIViewController {\n \n @IBOutlet weak var