UIFont

class UIFont : NSObject, NSCopying

This extesion adds some useful functions to UIFont.

  • All font family names available from iOS 7.0 to iOS 11.0.

    See more

    Declaration

    Swift

    public enum FamilyFontName : String
  • Static light font to use in App.

    Default is HelveticaNeueLight of size 12.

    Declaration

    Swift

    @available(*, deprecated: 3.2, message: "`lightFont` is deprecated and will be removed in a future version of BFKit-Swift.")
    @nonobjc
    public static var lightFont: UIFont?
  • Static regular font to use in App.

    Default is HelveticaNeue of size 12.

    Declaration

    Swift

    @available(*, deprecated: 3.2, message: "`regularFont` is deprecated and will be removed in a future version of BFKit-Swift.")
    @nonobjc
    public static var regularFont: UIFont?
  • Static bold font to use in App.

    Default is HelveticaNeueBold of size 12.

    Declaration

    Swift

    @available(*, deprecated: 3.2, message: "`boldFont` is deprecated and will be removed in a future version of BFKit-Swift.")
    @nonobjc
    public static var boldFont: UIFont?
  • Create an UIFont object from the given font name and size, may returns an Helvetica font, if the given font doesn’t exist.

    Declaration

    Swift

    public convenience init?(fontName: FontName, size: CGFloat)

    Parameters

    fontName

    Font name.

    size

    Size of the font.

  • Print in console all family and font names.

    Declaration

    Swift

    public static func allFonts() -> [String : [String]]

    Return Value

    Returns all the font family names.

  • Calculate text height for max width and font.

    Declaration

    Swift

    public static func calculateHeight(width: CGFloat, font: UIFont, text: String) -> CGFloat

    Parameters

    width

    Max width to fit text.

    font

    Font used in text.

    text

    Text.

    Return Value

    Returns calculated height of string within width using given font.

  • Calculate text height for max width and font.

    Declaration

    Swift

    public static func calculateHeight(width: CGFloat, font: FontName, fontSize: CGFloat, text: String) -> CGFloat

    Parameters

    width

    Max width to fit text.

    font

    Font used in text, from FontName enum.

    size

    Font size.

    text

    Text.

    Return Value

    Returns calculated height of string within width using given font

  • Print in console all font names for a given family.

    Declaration

    Swift

    public static func fontNames(for family: FamilyFontName) -> [Any]

    Parameters

    familyFontName

    Family fonts.

    Return Value

    Returns all fonts for the given family.