Sha256: fb629386e8565480fe184dbca0985408dffd0f1e19718b7237ab7e3438a5f497

Contents?: true

Size: 630 Bytes

Versions: 12

Compression:

Stored size: 630 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 new() 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

12 entries across 12 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.5.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.4.2 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.4.1 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.4.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.7 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.6 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.5 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.4 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.3 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.2 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.3.1 lib/ios/sugarcube-factories/uilabel.rb