import { curves } from '@kit.ArkUI';
@Entry
@Component
struct Index {
@State widthValue: number = 38;
@State scaleValue: number = 1;
@State iterations: number = -1;
build() {
Column(){
Text('开始')
.fontSize(16)
.width(40).height(20)
.onClick(()=>{
animateTo({
duration: 450,
curve: Curve.EaseInOut,
iterations: this.iterations,
playMode:PlayMode.Alternate,
onFinish: () => {
console.log('--哈哈哈---')
}
}, () => {
this.scaleValue = 1.2
})
})
Text('结束')
.fontSize(16)
.width(40).height(20)
.margin({top:20})
.onClick(()=>{
this.iterations = 1
})
Stack({alignContent:Alignment.Center}){
Row()
.width(32)
.height(32)
.backgroundColor(Color.Orange)
.borderRadius(16)
.scale({x:this.scaleValue,y:this.scaleValue})
Row(){
}
.width(this.widthValue)
.height(this.widthValue)
.backgroundColor(Color.Transparent)
.borderRadius(1080)
.borderWidth(2)
.borderColor(Color.Red)
.scale({x:this.scaleValue,y:this.scaleValue})
}.margin({top:50})
}.margin({left:200,top:150})
}
}
iterations设置为-1后,应该怎么手动结束动画
可以通过新启一个duration为0的animateTo来结束动画
参考链接:https://gitee.com/XiaoBaiAHui/arkui\_animation\_fag