Skip to content

Instantly share code, notes, and snippets.

@nuno
Forked from rborn/ImageHelper.js
Created September 19, 2013 01:57
Show Gist options
  • Select an option

  • Save nuno/6618203 to your computer and use it in GitHub Desktop.

Select an option

Save nuno/6618203 to your computer and use it in GitHub Desktop.
// Assuming you have the images following images, this should work fine
// images/background@2x.png
// images/background-568h@2x.png
require("ImageHelper");
var window = Titanium.UI.createWindow({
title: "My awesome window",
backgroundImage: parse568hImages("/images/background.png")
});
// I am pretty sure there is a sexier approach, but this works nicely
var isPhone5 = Ti.Platform.displayCaps.platformHeight == 568;
parse568hImages = function(imagePath) {
if (isPhone5){
// Do this because the filename could contain dots
imagePath = imagePath.replace(".png","-568h@2x.png");
imagePath = imagePath.replace(".jpg","-568h@2x.jpg");
imagePath = imagePath.replace(".jpeg","-568h@2x.jpeg");
}
return imagePath;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment