2016-05-17 50 views

回答

2

在NativeScript你只能改變隔膜的顏色與物業separatorColor
但是你可以使用原生的iOS API更改默認的分隔符利潤率(使用NativeScript是訪問本機API的好處之一)下面是一個例子代碼:

function onLoaded(args) { 
    page = args.object; 
    page.bindingContext = { "items": allItemsViewModel }; 

    var listView = page.getViewById("all-items"); 
    var tableView = listView.ios; 
    for (var i = 0; i < allItemsViewModel.length; i++) { 
     var cellIndexPath = NSIndexPath.indexPathForItemInSection(i, 0); 
     var cell = tableView.cellForRowAtIndexPath(cellIndexPath); 
     if (cell !== null) { 
      cell.preservesSuperviewLayoutMargins = false; 
      cell.separatorInset = UIEdgeInsetsZero; 
      cell.layoutMargins = UIEdgeInsetsZero; 
     } 
    } 
} 
2

或者你可以只設置分隔符顏色爲透明

<ListView items="{{ itemsArray}}" separatorColor="#00000000"> 

然後在itemTemplate創建您自己的分隔符,並直接從XML控制幅度,高度,顏色,ECT:

<ListView.itemTemplate> 
    <StackLayout> 
    ... 
    <StackLayout backgroundColor="#708090" height="1"/> 
    <StackLayout> 
</ListView.itemTemplate>