Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove ListView item highlight on tap Nativescript Angular iOS

I would like to remove default behaviour on the ListView on iOS - highlight items on tap. I tried with setting the background color. And it didn't work out. I found this issue on github https://github.com/NativeScript/NativeScript/issues/455 however I don't know how to achieve this in Angular nativescript

like image 752
TomOw Avatar asked Dec 02 '22 12:12

TomOw


1 Answers

Set the itemLoading event on the list view like this:

<ListView [items]="items" (itemLoading)="onItemLoading($event)">

Then in your typescript, define your onItemLoading event like this:

import { isIOS } from 'tns-core-modules/platform';
declare var UITableViewCellSelectionStyle;
// ...
onItemLoading(args: ItemEventData) {
  if (isIOS) {
    const iosCell = args.ios;
    iosCell.selectionStyle = UITableViewCellSelectionStyle.None;
  }
}

FYI - I tested this on nativescript-angular version 3.1.0 and tns-core-modules version 3.3

like image 111
morecchia808 Avatar answered Dec 28 '22 06:12

morecchia808