Text

public struct Text : View
extension Text: Renderable

A view that represents a read only text

  • Declaration

    Swift

    public var viewStore: ViewValues
  • Declaration

    Swift

    public var string: String
  • Creates a text view based on a unlocalized string

    Declaration

    Swift

    public init(verbatim string: String)
  • Creates a text view based on a unlocalized string

    Unlike SwiftUI, calling this will result in the same of calling init(verbatim:). If you want to use localized strings, use init(key:) instead.

    Declaration

    Swift

    public init<S>(_ content: S) where S : StringProtocol
  • Creates a text view based on a localized string. If the localized string cannot be located, the value of key will be used instead.

    Declaration

    Swift

    public init(key: String, tableName: String? = nil, bundle: Bundle? = nil, comment: StaticString? = nil)

    Parameters

    key

    The key of the localized string. It’s value will be used if the localized string cannot be found.

    tableName

    The name of the table to look for the localized string. If not specified, the strings defined in Localizable.strings will be used.

    bundle

    The bundle to search in.

    comment

    A description of this string. Only for reference.

  • Declaration

    Swift

    public var body: View { get }
  • Sets the strikethrough style of the text, optionally with a separate color. Not passing a color or passing nil will use the same foreground color as the text.

    Declaration

    Swift

    public func strikethrough(_ active: Bool = true, color: Color? = nil) -> Text
  • Applies an underline to the text.

    Declaration

    Swift

    public func underline(_ active: Bool = true, color: Color? = nil) -> Text

    Parameters

    active

    A Boolean value that indicates whether the text has an underline.

    color

    The color of the underline. If color is nil, the underline uses the default foreground color.

    Return Value

    Text with a line running along its baseline.

  • Sets the minimum amount that text in this view scales down to fit in the available space.

    Use the minimumScaleFactor(_:) modifier if the text you place in a view doesn’t fit and it’s okay if the text shrinks to accommodate. For example, a label with a minimumScaleFactor of 0.5 draws its text in a font size as small as half of the actual font if needed.

    Declaration

    Swift

    public func minimumScaleFactor(_ factor: CGFloat) -> Text

    Parameters

    factor

    A fraction between 0 and 1 (inclusive) you use to specify the minimum amount of text scaling that this view permits.

    Return Value

    A view that limits the amount of text downscaling.

  • Returns the result of combining two texts. The properties of each text is maintained even after the combination.

    Declaration

    Swift

    public static func + (left: Text, right: Text) -> Text
  • Declaration

    Swift

    public func updateView(_ view: UIView, context: Context)
  • Declaration

    Swift

    public func createView(context: Context) -> UIView