Sha256: f2772d55937f687e92b7094e10b14b73859d233caef77183050aacf71151ce3a

Contents?: true

Size: 593 Bytes

Versions: 27

Compression:

Stored size: 593 Bytes

Contents

class UILabel

  # UILabel.new('test')
  # UILabel.new('test', another_label.font)
  # UILabel.new('test', 'Helvetica')
  # UILabel.new('test', 'Helvetica', 20)
  def self.new(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

27 entries across 27 versions & 1 rubygems

Version Path
sugarcube-3.2.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.1.1 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.1.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.8 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.7 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.6 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.5 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.4 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.3 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.2 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.1 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-3.0.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.12.3 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.12.2 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.12.1 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.12.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.11.1 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.11.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.10.0 lib/ios/sugarcube-factories/uilabel.rb
sugarcube-2.9.1 lib/ios/sugarcube-factories/uilabel.rb