Set anchorpoint for rotation in Titanium -
how can set anchor-point rotation of image.
over here, need place other images in rotated/tilted manner w.r.t first image. need set anchor-point of rotation first image
on android have set anchor point on transform matrix. on ios have set anchor point view trying rotate.
important undocumented behaviour: i've been struggling week , found out following: if try set anchorpoint view without first setting it's width or height, or setting them ti.ui.size anchorpoint @ 0,0.
you can try code snippet should work. haven tested it, can idea. code should work both platforms.
var anchor_x = 0.5; var anchor_y = 0.5; var view = ti.ui.createview({ // set height , width!!!! // if not anchor calculated width = 0 , height = 0 width: ti.ui.fill height: ti.ui.fill }); // it's ios (ipad or iphone) if (ti.platform.platform == 'iphone os') view.anchorpoint = {x: anchor_x, y: anchor_y}; var transform; // if it's android, create 2dmatrix desired anchorpoint. if (ti.platform.platform == 'android') transform = ti.ui.create2dmatrix({anchorpoint: { x: anchor_x, y: anchor_y }}); else transform = ti.ui.create2dmatrix(); // apply rotation transform = transform.rotate(90); // apply transformation view. view.transform = transform;
Comments
Post a Comment