Rotate image continiously in iPhone apps using Titanium.
Rotate an image continiously. Let say we have an image and I want to rotate it 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().rotate(45); //Defines the Animation var myAnimation = Ti.UI.createAnimation({ transform : imgTransform, //Transform property to change during animation duration : 800 //Duration for the animation in millisecond }); //Repeat the animation myAnimation.addEventListener('complete', function(){ imgTransform = imgTransform.rotate(45); myAnimation.transform = imgTransform; //Show the animation effect. myImg.animate(myAnimation); }); //Show the animation effect. myImg.animate(myAnimation);