NativeScript位置弹出窗口
具有x和y位置的NativeScript弹出窗口。
npm i --save nativescript-popup-with-position

npm npm

安装

tns plugin add nativescript-popup-with-position

用法

    <Button tap="openPopup"/>
    import { Popup } from 'nativescript-popup-with-position';

function openPopup(args){
const popup = new Popup({
backgroundColor:'white' | '#fff',
height:100,
width:100,
unit:'dp' | 'px' | '%',
elevation:10, // android only
borderRadius:25 // android only
});
const view = new Label();
view.text = "Test";

/* IOS */
const nativeView = UILabel.new();
nativeView.text = "Native Button";
nativeView.frame = CGRectMake(0,0,50,50);
/* -- IOS */

/* Android */
const nativeView = new new android.widget.TextView(context);
nativeView.setText("Native Button");
nativeView.setWidth(50);
nativeView.setHeight(50);
/* -- Android */
let xpos = 0;
let ypos = 0;

popup.showPopup(anchor: View | nativeView , view: View | nativeView, xpos , ypos);
}

API

构造函数

Popup(options: PopupOptions)

构造函数示例

import { Popup, PopupOptions } from "nativescript-popup-with-position";

const opts: PopupOptions = {
backgroundColor: "white" | "#fff",
height: 100,
width: 100,
unit: "dp" | "px" | "%",
elevation: 10, // android only
borderRadius: 25 // android only
};

const popup = new Popup(opts);

Popup方法

方法 描述
showPopup(source: any, view: any): Promise 显示锚定到source参数的弹出窗口,其中view参数作为弹出内容。view参数可以是本机Android/iOS视图、NativeScript视图或指向app目录中模板的字符串路径。
hidePopup(data?: any): Promise 隐藏弹出窗口并将其从视图层次结构中删除。

许可

Apache License Version 2.0, January 2004