The UISegmentedControl provided by UIKit is a ubiquitous control. However, when it comes to customizing this control, it can get pretty tricky. So I’m going to try to explain how this widget can be styled to better match your app by walking through a few different customizations.
The image below shows the different styles we will build.
UILabel and UITextView both rely on TextKit to render text. So why do they behave differently and how can they work together?
Below is a view with a UILabel (blue) and two UITextViews (red) laid out in IB.
The Label is constrained to the top right corner of the view and uses it’s intrinsic content size to determine the width and height. The size of the label matches closely to the size of the text.