nativeScript-scratchview
Nativescript 插件,用于实现刮刮卡视图
npm i --save nativescript-scratchview

Nativescript Scratch View (仅限 Android)

Nativescript 插件,用于实现刮刮卡功能。

Screenshot of Android

安装

从您项目的根目录运行以下命令

tns plugin add nativescript-scratchview

使用方法

您需要将 xmlns:sv="nativescript-scratchview" 添加到您的页面标签中,然后只需使用 <sv:ScratchView> 就可以在页面上添加小部件。

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" xmlns:sv="nativescript-scratchview">
<GridLayout rows="*" columns="*">
<sv:ScratchView id="scratchView" height="250" width="250" strokeWidth="10" revealed="{{revealed}}" percentRevealed="{{percentRevealed}}">
<Image height="250" width="250" stretch="aspectFill" src="~/images/back.jpg"></Image>
<Image height="250" width="250" stretch="aspectFill" src="~/images/scratch.jpg"></Image>
</sv:ScratchView>
</GridLayout>
</Page>

API

属性 默认值 描述
strokeWidth 10 刮擦线条宽度

事件

  • revealed
    当刮擦视图刮擦到100%时触发。

  • percentRevealed
    每次刮擦视图刮擦时触发。 参数 事件.percent - 刮擦视图刮擦的百分比

方法

  • reveal
    清除刮擦并揭示后面的视图。

许可

Apache License 版本 2.0,2004年1月