Second-Tap Feedback
With the ability to detect a second tap, the user can be provided feedback of a reselection, such as changing the title in the navigation bar. Another alternative is modifying the attributes of the text in the segmented control. UIKit’s text attribute feature (first introduced in iOS 5.x) offers an excellent match to this challenge. Segment controls provide optional attributes based on state. The setTitleTextAttributes:forState: method lets you introduce a visual flourish limited to the selected segment. Recipe 2-4 uses this method to change the selected text color from white to red after a second tap, and it resets that change after the user selects an alternate segment, as shown in Figure 2-5.
Figure 2-5 By detecting the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access