rotation - Rotate a label around its center -


i trying rotate label around center , have following code. however, it's not getting rotated around center, around view. how can fix problem?

var singlelabel = titanium.ui.createlabel({     backgroundcolor:'red',     text: i+1,     top: 100,     width: 35,     height:20, });  singlelabel.setanchorpoint({x: 0,y:0}); var rotatefirst = titanium.ui.create2dmatrix().rotate(270); singlelabel.transform = rotatefirst; 

the anchor point of titanium view defined :

enter image description here

  • the x property match x axe
  • the y property match y axe

thus, if want rotate view/label/... around it's center, have use { x: 0.5, y: 0.5 } anchor point.

if want convince yourself, can play code :

var self = ti.ui.createview();  var label = ti.ui.createlabel({     text:        'reference text',     color:       '#000000',     bordercolor: '#000000' }); self.add(label);  var label2 = ti.ui.createlabel({     text:        'reference text',     color:       '#ff0000',     bordercolor: '#ff0000' }); self.add(label2);  var rotation = ti.ui.create2dmatrix({rotate: 90}); label2.setanchorpoint({x: 1,y:1}); label2.transform = rotation; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -