Sha256: 1ba4af0ef4f5c09c87d7a09313271d74616041a149d7cd94ffca0668554d77ea

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

class UILabel

  # @example
  #     UILabel.label('test')
  #     UILabel.label('test', another_label.font)
  #     UILabel.label('test', 'Helvetica')
  #     UILabel.label('test', 'Helvetica', 20)
  def self.label(text=nil, font=nil, size=nil)
    return super() if text.nil?

    font = font.uifont(size) if font.respond_to?(:uifont)
    label = self.alloc.initWithFrame([[0, 0], [0, 0]])
    if text.is_a?(NSAttributedString)
      label.attributedText = text
    else
      label.text = text
    end
    if font
      label.font = font
    end
    label.backgroundColor = :clear.uicolor
    label.sizeToFit
    label
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sugarcube-3.3.0 lib/ios/sugarcube-factories/uilabel.rb