UILabel

class UILabel : UIView, NSCoding, UIContentSizeCategoryAdjusting

This extesion adds some useful functions to UILabel.

  • Create an UILabel with the given parameters.

    Declaration

    Swift

    public convenience init(frame: CGRect, text: String, font: UIFont, color: UIColor, alignment: NSTextAlignment, lines: Int, shadowColor: UIColor = UIColor.clear)

    Parameters

    frame

    Label frame.

    text

    Label text.

    font

    Label font.

    color

    Label text color.

    alignment

    Label text alignment.

    lines

    Label text lines.

    shadowColor

    Label text shadow color.

  • Create an UILabel with the given parameters.

    Declaration

    Swift

    public convenience init(frame: CGRect, text: String, font: FontName, fontSize: CGFloat, color: UIColor, alignment: NSTextAlignment, lines: Int, shadowColor: UIColor = UIColor.clear)

    Parameters

    frame

    Label frame.

    text

    Label text.

    font

    Label font name.

    size

    Label font size.

    color

    Label text color.

    alignment

    Label text alignment.

    lines

    Label text lines.

    shadowColor

    Label text shadow color.

  • Calculates height based on text, width and font.

    Declaration

    Swift

    public func calculateHeight() -> CGFloat

    Return Value

    Returns calculated height.

  • Sets a custom font from a character at an index to character at another index.

    Declaration

    Swift

    public func setFont(_ font: UIFont, fromIndex: Int, toIndex: Int)

    Parameters

    font

    New font to be setted.

    fromIndex

    The start index.

    toIndex

    The end index.

  • Sets a custom font from a character at an index to character at another index.

    Declaration

    Swift

    public func setFont(_ font: FontName, fontSize: CGFloat, fromIndex: Int, toIndex: Int)

    Parameters

    font

    New font to be setted.

    fontSize

    New font size.

    fromIndex

    The start index.

    toIndex

    The end index.