UISegmentedControl text with multiple lines?

Jason picture Jason · Apr 10, 2011 · Viewed 17.4k times · Source

How can I make the text in one of the buttons in my UISegmentedControl span multiple lines?

Answer

Saranya Sivanandham picture Saranya Sivanandham · May 23, 2015

Use UIAppearance to get things done. The below code snippet will work. Call this before creating your segment.

Objective-C

[[UILabel appearanceWhenContainedIn:[UISegmentedControl class], nil] setNumberOfLines:0];

Swift

UILabel.appearanceWhenContainedInInstancesOfClasses([UISegmentedControl.self]).numberOfLines = 0