mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Button added
This commit is contained in:
36
ui/button/button.ios.ts
Normal file
36
ui/button/button.ios.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import observable = require("ui/core/observable");
|
||||
import view = require("ui/core/view");
|
||||
import application = require("application");
|
||||
|
||||
export class Button extends view.View {
|
||||
private static textProperty = "text";
|
||||
private _ios: UIKit.UIButton;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._ios = UIKit.UIButton.buttonWithType(UIKit.UIButtonType.UIButtonTypeRoundedRect);
|
||||
|
||||
var that = this;
|
||||
var target = Foundation.NSObject.extends({ click: (args) => { that.emit("click"); } }, { exposedMethods: { "click:": "v@:@" } });
|
||||
this._ios.addTargetActionForControlEvents(new target(), "click:", UIKit.UIControlEvents.UIControlEventTouchUpInside);
|
||||
}
|
||||
|
||||
get ios(): UIKit.UIButton {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return this.ios.titleForState(UIKit.UIControlState.UIControlStateNormal);
|
||||
}
|
||||
set text(value: string) {
|
||||
this.setProperty(Button.textProperty, value);
|
||||
}
|
||||
|
||||
public setNativeProperty(data: observable.PropertyChangeData) {
|
||||
if (data.propertyName === Button.textProperty) {
|
||||
this.ios.setTitleForState(data.value, UIKit.UIControlState.UIControlStateNormal);
|
||||
} else if (true) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user