Sha256: ce1aac1d38aed5a91f9aa6b447c630f3df9f1792f6a16b62d2b812ec3cd36b62

Contents?: true

Size: 807 Bytes

Versions: 54

Compression:

Stored size: 807 Bytes

Contents

class NSString

  # @return [UIImage]
  def uiimage
    UIImage.imageNamed(self).tap do |retval|
      NSLog("No image named #{self}") unless retval
    end
  end

  # @return [UIFont]
  def uifont(size=nil)
    size ||= UIFont.systemFontSize
    UIFont.fontWithName(self, size:size)
  end

  # @param font [UIFont] Optional, defaults to UIFont.systemFontOfSize(UIFont.systemFontSize)
  # @return [UILabel]
  def uilabel(font=nil)
    font ||= :system.uifont(UIFont.labelFontSize)
    size = self.sizeWithFont(font)
    label = UILabel.alloc.initWithFrame([[0, 0], size])
    label.text = self
    label.font = font
    # why isn't this just the default!?
    label.backgroundColor = :clear.uicolor
    return label
  end

  # @return [UIImageView]
  def uiimageview
    self.uiimage.uiimageview
  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.5.0 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.4.2 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.4.1 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.4.0 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.7 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.6 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.5 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.4 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.3 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.2 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.1 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.3.0 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.2.0 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.1.1 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.1.0 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.0.8 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.0.7 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.0.6 lib/ios/sugarcube-ui/nsstring.rb
sugarcube-3.0.5 lib/ios/sugarcube-ui/nsstring.rb