Sha256: 5b5209e382ad7ea8d30c4504b481563207f9e8ac0153bf1aa2d957fc18618a98

Contents?: true

Size: 1.13 KB

Versions: 117

Compression:

Stored size: 1.13 KB

Contents

class UIImage
  class << self
    SugarCube568_TallSuffix = '-568h@2x'

    def imageNamed568(name)
      @may_use_taller_images ||= CGSizeEqualToSize(CGSizeMake(320, 568), UIScreen.mainScreen.bounds.size)
      if ( @may_use_taller_images && name.length > 0  && name.rangeOfString(SugarCube568_TallSuffix).location == NSNotFound )
        # Check if is there a path extension or not
        test_name = name;
        if test_name.pathExtension.length > 0
          test_name = test_name.stringByDeletingPathExtension.stringByAppendingString(SugarCube568_TallSuffix).stringByAppendingPathExtension(name.pathExtension)
        else
          test_name = test_name.stringByAppendingString(SugarCube568_TallSuffix + ".png")
        end

        image = imageNamed_old(test_name)
        if image
          return self.imageWithCGImage(image.CGImage, scale:2.0, orientation:image.imageOrientation)
        end
      end

      return nil
    end

    alias :imageNamed_old :imageNamed
# now we've got imageNamed568 and imageNamed_old to load the respective versions

    def imageNamed(name)
      imageNamed568(name) || imageNamed_old(name)
    end
  end
end

Version data entries

117 entries across 117 versions & 1 rubygems

Version Path
sugarcube-2.8.1 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.8.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.7.1 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.7.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.6.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.5.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.4.2 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.4.1 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.4.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.3.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.2.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.1.5 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.1.4 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.1.3 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.1.2 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.1.1 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.1.0 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.0.2 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.0.1 lib/ios/sugarcube-568/uiimage.rb
sugarcube-2.0.0 lib/ios/sugarcube-568/uiimage.rb