Continious image scale in and out in iPhone using animation with Titanium.
Continiously we can do image scale in and out animation using titanium. Let say we have image and I want to scale up/down continiously. So here is the code to do that described below.
Code Block :
//Define the current window var myWin = Ti.UI.currentWindow; //Define the Image var myImg = Ti.UI.createImageView({ width : 50, //Describes the width height : 50 //Describes the height }); //Set the image for the image view myImg.backgroundImage = "Test_Image_Path"; //Add the image to the current window myWin.add(myImg); //Create the transformation var imgTransform = Ti.UI.create2DMatrix(); //Set the transform effect scale down to half of the state imgTransform = imgTransform.scale(0.5); //Scalling have the range from 1 to 0 //Defines the Animation var myAnimation = Ti.UI.createAnimation({ transform : imgTransform, //Transform property to change during animation duration : 800, //Duration for the animation in millisecond autoreverse : true //To do the animation in reverse order }); //Show the animation effect myImg.animate(myAnimation); //Now complete of each animation, the new animation start on image myAnimation.addEventListener('complete', function(){ //Show the animation effect myImg.animate(myAnimation); });