是否可以在Titanium Label中指定包装文本行之间的间距?我无法看到这样做的方法吗?
答案 0 :(得分:5)
实现它的一种方法是使用属性字符串中的基线偏移:
var win = Ti.UI.createWindow();
var text = "The history of all hitherto existing society is the history of class struggles. Freeman and slave, patrician and plebeian, lord and serf, guild-master and journeyman, in a word, oppressor and oppressed, stood in constant opposition to one another, carried on an uninterrupted, now hidden, now open fight, a fight that each time ended, either in a revolutionary reconstitution of society at large, or in the common ruin of the contending classes.";
var attr = Ti.UI.iOS.createAttributedString({
text: text,
attributes: [
{
type: Ti.UI.iOS.ATTRIBUTE_BASELINE_OFFSET,
value: 20,
range: [0,250]
}
]
});
var label = Ti.UI.createLabel({
attributedString: attr,
color:'white',
width:Ti.UI.FILL,
height:500
});
win.add(label);
win.open();