String

extension String
  • Crops string by specified width and font

    Declaration

    Swift

    func crop(by width: CGFloat, font: SFWFont) -> String

    Parameters

    width

    Maximum width for string

    font

    Font for string

    Return Value

    Cropped string

  • Replaces characters with dots at the end

    Declaration

    Swift

    mutating func replaceLastCharactersWithDots(count: Int = 3)

    Parameters

    count

    last character count

  • Сounts the right amount of lines for text

    Declaration

    Swift

    func linesCount(for font: SFWFont, spacing: CGFloat) -> Int

    Parameters

    font

    Font

    spacing

    Spacing between lines

    Return Value

    Right amount of lines for text

  • Splits String to lines

    Declaration

    Swift

    func split(font: SFWFont, lineWidths: [CGFloat], lineBreak: TextPreferences.LineBreakMode, splitCharacter: String = " ") -> [String]

    Parameters

    font

    Font

    lineWidths

    Each line width

    lineBreak

    Line break type

    splitCharacter

    Split by the specified character

    Return Value

    List of split strings to lines

  • Avalilable width for text with specified font

    Declaration

    Swift

    func width(by font: SFWFont) -> CGFloat

    Parameters

    font

    Font

    Return Value

    Text width