npm i --save nativescript-scratchview
- 版本:1.0.0
- GitHub: https://github.com/mehulcs/nativescript-scratchview
- NPM: https://npmjs.net.cn/package/nativescript-scratchview
- 下载次数
- 昨天:0
- 上周:2
- 上个月:10
Nativescript Scratch View (仅限 Android)
Nativescript 插件,用于实现刮刮卡功能。
安装
从您项目的根目录运行以下命令
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月