在Titanium的坐标处放置一个标签

时间:2013-07-18 11:34:32

标签: label titanium coordinates titanium-mobile

我创建了一个标签,并希望将其放在某些坐标上。有没有办法可以直接设置x和y坐标,将标签放在Titanium中。

1 个答案:

答案 0 :(得分:0)

非常简单,只需将topleft值设置为相应的Y和X值即可。这些是相对于标签父级的,如果您将父级layout属性设置为除composite以外的任何内容,则无法按预期工作:

var label1 = Ti.UI.createLabel({
  color: '#900',
  font: { fontSize:48 },
  text: 'A simple label',
  textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
  top: 30, // Your Y coordinate
  left : 20, // Your X coordinate
  width: Ti.UI.SIZE, height: Ti.UI.SIZE
});

Check this guide for more information关于观看和定位。