Label

public struct Label : ProxyElement

Displays text content.

  • The text to be displayed.

    Declaration

    Swift

    public var text: String
  • Declaration

    Swift

    public var font: UIFont
  • Declaration

    Swift

    public var color: UIColor
  • Declaration

    Swift

    public var alignment: NSTextAlignment
  • Declaration

    Swift

    public var numberOfLines: Int
  • Declaration

    Swift

    public var lineBreakMode: NSLineBreakMode
  • Declaration

    Swift

    public var lineHeight: LineHeight
  • A Boolean value that determines whether the label reduces the text’s font size to fit the title string into the label’s bounding rectangle.

    Normally, the label draws the text with the font you specify in the font property. If this property is true, and the text in the text property exceeds the label’s bounding rectangle, the label reduces the font size until the text fits or it has scaled the font down to the minimum font size. The default value for this property is false.

    If you change it to true, be sure that you also set an appropriate minimum font scale by modifying the minimumScaleFactor property.

    This autoshrinking behavior is only intended for use with a single-line label.

    Declaration

    Swift

    public var adjustsFontSizeToFitWidth: Bool
  • The minimum scale factor for the label’s text.

    If the adjustsFontSizeToFitWidth is true, use this property to specify the smallest multiplier for the current font size that yields an acceptable font size for the label’s text.

    If you specify a value of 0 for this property, the label doesn’t scale the text down. The default value of this property is 0.

    Declaration

    Swift

    public var minimumScaleFactor: CGFloat
  • A Boolean value that determines whether the label tightens text before truncating.

    When the value of this property is true, the label tightens intercharacter spacing of its text before allowing any truncation to occur. The label determines the maximum amount of tightening automatically based on the font, current line width, line break mode, and other relevant information.

    This autoshrinking behavior is only intended for use with a single-line label.

    The default value of this property is false.

    Declaration

    Swift

    public var allowsDefaultTighteningForTruncation: Bool
  • A shadow to display behind the label’s text. Defaults to no shadow.

    Declaration

    Swift

    public var shadow: TextShadow?
  • Determines if the label should be included when navigating the UI via accessibility.

    Declaration

    Swift

    public var isAccessibilityElement: Bool
  • A localized string that represents the current value of the accessibility element.

    The value is a localized string that contains the current value of an element. For example, the value of a slider might be 9.5 or 35% and the value of a text field is the text it contains.

    Declaration

    Swift

    public var accessibilityValue: String?
  • A localized string that describes the result of performing an action on the element, when the result is non-obvious.

    Declaration

    Swift

    public var accessibilityHint: String?
  • A set of accessibility traits that should be applied to the label, these will be merged with any existing traits.

    Declaration

    Swift

    public var accessibilityTraits: Set<AccessibilityElement.Trait>?
  • An array containing one or more AccessibilityElement.CustomActions, defining additional supported actions. Assistive technologies, such as VoiceOver, will display your custom actions to the user at appropriate times.

    Declaration

    Swift

    public var accessibilityCustomActions: [AccessibilityElement.CustomAction]
  • Declaration

    Swift

    public init(text: String, configure: (inout Label) -> Void = { _ in })
  • Declaration

    Swift

    public var elementRepresentation: Element { get }
  • Declaration

    Swift

    public enum LineHeight : Equatable