StackLayout 的背景动画
在点击按钮上动画 stacklayout 的背景颜色
页/ main.component.ts
import {Component, ElementRef, ViewChild} from "@angular/core";
import {Color} from "color";
import {View} from "ui/core/view";
@Component({
selector: "main",
template: `
<StackLayout #el>
<Button text="Apply Changes" (tap)="changeBgColor()"></Button>
</StackLayout>
`,
styleUrls: ["pages/main/main-common.css"],
})
export class MainComponent {
@ViewChild("el") el: ElementRef;
changeBgColor() {
let el = <View>this.el.nativeElement;
el.animate({
backgroundColor: new Color("#222"),
duration: 300
});
}
}
页/主 common.css
StackLayout{
background-color: #333;
}