Controls and Attributes
Beginning with iOS 6, many UIKit classes, including text fields, text views, labels, buttons, and refresh controls allow you to assign attributed (Core Text–style) strings to their text and title properties:
[myButton setAttributedTitle:attributedString forState:UIControlStateNormal]
In iOS 7, Apple expanded the vocabulary of text attributes such as font, color, and shadow that can be configured. A full listing of attributes that can be applied to text in an attributed string can be found in the NSAttributedString
class reference, under Character Attributes.
For segmented controls and bar items, set attributes by calling setTitleTextAttributes:forState:
. Pass an attribute dictionary using ...
Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.